将非托管本机库文件包括到nuget输出目录 [英] Including an unmanaged native library files to nuget output directory
问题描述
未共享的共享库(.so文件)不会复制到输出目录:
unamanged shared object (.so file) does not copy to the output directory:
我有一个.netstandard 2项目,该项目包装了一个c ++库(我们称其为wrap.csproj项目).该项目取决于共享库(libgdal.so).
I have .netstandard 2 project that wraps a c++ library(lets call the project wrap.csproj). That project depends on shared object (libgdal.so).
我想将此项目用作nuget,因此,引用我的nuget的项目应该在build/publish文件夹中包含wrap.dll和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.
我将此项目打包为nuget.但是引用此nuget的项目(dotnet核心)没有得到libgdal.so文件,只是得到build/published文件夹中的wrap.dll,因此我遇到了运行时错误.
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.
我将此属性添加到nuget csproj中:
I add this properties to the nuget csproj:
<ItemGroup>
<None Include="libgdal.so">
<Pack>true</Pack>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
从@zivkan的帮助中看了一眼后,我成功了
after a little look from the help here of @zivkan I succeed
我要做的就是添加如下的packagepath:
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>
推荐答案
我要做的就是像这样添加PackagePath:
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>
(我的运行时间是linux-x64)
(my run time is linux-x64)
这篇关于将非托管本机库文件包括到nuget输出目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!