Search code examples
.net-corepinvoke

In a cross-platform .NET Core executable, how can I specify paths to native dependencies / where do I put them?


I've been using p/invoke to call some native dependencies in a cross-platform web app on .NET Core. This only works because I've specifically installed and ldconfiged those dependencies.

Ideally I'd like to be able to run dotnet publish --self-contained against the appropriate platform and have that command include all the so files it needs, whereever they need to be, without ldconfig. I don't know if this is possible.

So my questions are:

  1. Where does .NET core look for native dependencies if you do not use ldconfig? Does it matter if its a web app?
  2. If the answer to (1) is not "nowhere," how can I include these dependencies when I do dotnet publish?

Solution

  • The self-contained option is meant to create a portable publish option. The output folder would contain all required native and any set up required to run in the specified platform without the need of installations. All dll dependencies must be in the bin folder.