When you publish a self-contained dotnet linux app for .net core 2.0, and run it on a brand new machine, you'll get this error:
Failed to load', error: libunwind.so.8: cannot open shared object file: No such file or directory
Failed to bind to CoreCLR at '/export/libcoreclr.so'
You can solve this by installing system packages, but for a truly self-contained publish, pull the missing libraries from the microsoft docker image, and into your app's output. You can put them in the publish directory and distribute them with your app.
Creating the project:
$ mkdir test && cd test
$ dotnet new console && dotnet publish -r linux-x64 --self-contained -o bin
If you run it on linux, expected result:
$ docker run -it -v $(pwd)/bin:/export ubuntu:latest /export/export
Failed to load', error: libunwind.so.8: cannot open shared object file: No such file or directory
Failed to bind to CoreCLR at '/export/libcoreclr.so'
Pull the libraries via docker (libunwind
and libicu
) and to your publish directory:
$ docker run -v $(pwd)/bin:/export microsoft/dotnet:2.0.0-sdk bash -c "cp /usr/lib/x86_64-linux-gnu/libicu* /export/"
$ docker run -v $(pwd)/bin:/export microsoft/dotnet:2.0.0-sdk bash -c "cp /usr/lib/x86_64-linux-gnu/libunwind* /export/"
Re-test:
$ docker run -it -v $(pwd)/bin:/export ubuntu:latest bash -c "LD_LIBRARY_PATH=/export /export/export"
Hello World
Success!