Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Including an unmanaged native library files to nuget output directory

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>
like image 314
pixel Avatar asked Oct 18 '25 14:10

pixel


1 Answers

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)

like image 70
pixel Avatar answered Oct 21 '25 04:10

pixel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!