I need to use native c
libraries in my library(that supports several Core
TF
s and .net framework
) which is published via nuget. I configured it via .csproj
file and runtimes
folder. But I noticed that when I consume my NuGet via dotnet add package ..
in some cases, the native libraries are not copied into the expected folder after consuming, however when I use the VS
UI Nuget package manager
->Manage Nuget Packages for Solution
, all files are placed into correct places.
So, I assume that Nuget package manager
makes more steps than just call dotnet add package ..
, but it's unclear what exactly happens, any help will be appreciated.
Actually, dotnet add package
does the same effect as Nuget package manager UI in VS IDE. They simply install a Nuget package into your project and there is no difference. No additional operations will be performed. Like add some xml node in
So I think there is something else wrong in your project.
Please check under tips to troubleshoot your issue:
1) clean nuget caches first or just delete all cache files under C:\Users\xxx(current user)\.nuget\packages
.
2) And if the runtimes
folder does not exist under your project, I think it is controlled by dependency assets
. Like ExcludeAssets=runtime or native
. It will prevent the function of runtimes
folder. Please see this official document.
So after you finishing installing the nuget package, you should check your csproj
file, and make sure that there is no such like
<ExcludeAssets>runtime;native</ExcludeAssets>
under PackageReference node.
If there is any this node, please delete it.
3) delete bin
and obj
folder. Then rebuild your project to test again. Or if you use dotnet command line, you should additionally add dotnet build
command. In my side, I run dotnet build -p:platform=xxx;Configuration=Release
.