Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

Can't find .so file in nuget package when deployed via Docker

$
0
0

I've written a nuget package that uses some compiled rust code and want to be able to use this package on both linux and windows. I've compiled the rust code to a .dll and .so, and included both in the nuget package. Including the nuget package in my .net core project and testing locally on windows works fine. The issue comes when I deploy my .net core project within a docker container, to my linux based web server. Whenever any code in the nuget package that requires the .so gets called, I receive the exception:

Unable to load shared library 'opaque' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable: /usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.4/opaque.so: cannot open shared object file: No such file or directory/app/opaque.so: cannot open shared object file: No such file or directory/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.4/libopaque.so: cannot open shared object file: No such file or directory/app/libopaque.so: cannot open shared object file: No such file or directory/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.4/opaque: cannot open shared object file: No such file or directory/app/opaque: cannot open shared object file: No such file or directory/usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.4/libopaque: cannot open shared object file: No such file or directory/app/libopaque: cannot open shared object file: No such file or directory

This error is pretty easy to understand, I'm just not sure how to fix it. I'm pretty sure this issue is due to deploying via docker, as normally, it seems like nuget pacakges installed on linux will be placed in the /share/ directory, hence that's why its trying to find it there. I assume installing the nuget package from within the docker container is preventing this though.

Does anybody know how to fix this? Either specify a different path or somehow have my nuget package installed to the right directory?

I'm referencing the dll via attribute like so:

[DllImport("opaque")]

The nuget package structure looks like this:

project/    .dll    .so    .csproj

Here is how I'm specifying the .dll and .so in the project file

<ItemGroup><None Update="libopaque.so"><Pack>True</Pack><PackagePath>lib\$(TargetFramework)</PackagePath><CopyToOutputDirectory>Always</CopyToOutputDirectory></None><None Update="opaque.dll"><Pack>True</Pack><PackagePath>lib\$(TargetFramework)</PackagePath><CopyToOutputDirectory>Always</CopyToOutputDirectory></None></ItemGroup>

I tried this answer here, but I could not get it to work. I also tried changing the <PackagePath> for the .so file in the package file to app/, but that did not work.

Docker file looks like this. The nuget package is included in the STS project

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS buildWORKDIR /app# copy csprojs and restore as distinct layersWORKDIR /srcCOPY ["./STS/STS.csproj", "STS/"]COPY ["./Business/Business.csproj", "Business/"]RUN dotnet restore "STS/STS.csproj"# copy everything else and buildCOPY . ./WORKDIR "/src/STS"RUN dotnet build "STS.csproj" -c Release -o /app/build -r linux-x64FROM build AS publishRUN dotnet publish "STS.csproj" -c Release -o /app/out -r linux-x64# build runtime imageFROM mcr.microsoft.com/dotnet/sdk:8.0WORKDIR /appCOPY --from=publish /app/out .ENTRYPOINT ["dotnet", "STS.dll"]

Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>