ektrah/libsodium-core

Using in a Visual Studio extension

Closed this issue · 2 comments

I'm trying to use this in a Visual Studio extension to work with GitHub.com secret storage (per their documentation, this is the library preferred).

Because this is a native wrapper, a few things are not happening...

  • The dependent package libsodium.dll are actually not being packaged into my extension
  • Even after manually copying the /runtimes folder from the dependent package, I believe I'm hitting DllNotFoundException in Initialize

I'm curious if you've faced this before ideally specifically in this use case, or perhaps another where the hosting model of the calling component might be different. Essentially I'm needing initialize to be directed where to do the DllLoad...

ektrah commented

The locations where the runtime looks for native libraries vary between the different versions of .NET Framework/.NET Core/.NET. There is an open issue since 2018 asking how to properly pack native libraries in NuGet packages. However, this doesn't seem to be a priority for Microsoft, so no one knows exactly what needs to be done, particularly for such obscure cases as Visual Studio extensions 🤷‍♂️

One thing you could try would be to add the 64-bit libsodium.dll directly as a project item to your Visual Studio extension and set "Build Action" to "Content" and "Copy To Output Directory" to "Copy always" or "Copy if newer".

Thanks @ektrah this is what I ended up exactly doing actually your suggestion and "it works on my machine" :-). I'm actually chatting with the NuGet folks (I work on the .NET team) about this scenario. VSIX also has a lot of weird things given how the app is hosted.