问题描述
未管理的共享对象(.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
我需要做的就是像这样添加包路径:
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 输出目录中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!