Including an unmanaged native library files to nuget output directory

懵懂的女人 提交于 2021-01-27 12:59:27

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!