问题
unamanged shared object (.so file) does not copy to the output directory:
I have .netstandard 2 project that wraps a c++ library(lets call the project wrap.csproj). That project depends on shared object (libgdal.so).
I want to use this project as a nuget, and therefor, the projects that will reference my nuget should have the wrap.dll and the libgdal.so in the build/publish folder.
I packed this project as nuget. but projects( dotnet core) that reference this nuget does not get the libgdal.so file just the wrap.dll in the build/published folder and therefore I am getting run time error.
I add this properties to the nuget csproj:
<ItemGroup>
<None Include="libgdal.so">
<Pack>true</Pack>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
EDIT: after a little look from the help here of @zivkan I succeed
all I needed to do is to add the packagepath like that:
<ItemGroup>
<None Include="libgdal.so">
<Pack>true</Pack>
<PackagePath>runtimes/linux-x64/native</packagePath>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
回答1:
all I needed to do is to add the PackagePath like that:
<ItemGroup>
<None Include="libgdal.so">
<Pack>true</Pack>
<PackagePath>runtimes/linux-x64/native</PackagePath>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
(my run time is linux-x64)
来源:https://stackoverflow.com/questions/57394400/including-an-unmanaged-native-library-files-to-nuget-output-directory