A fatal error was encountered. The library 'libhostpolicy.so' required
For me it was the following line that I had to add to the project file's PropertyGroup section that did the trick:
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
After even more googling, we found this link:
http://szahariev.blogspot.co.nz/2016/10/libhostpolicyso-was-not-found-error.html
which lead us to discover that we'd somehow managed to manually remove the (in our case) <OutputType>Exe</OutputType>
line from our .csproj file. So no runtimeconfig.json was created at all.
In my case the problem was specified .dll to run was incorrect (library instead of web application).
First I acvieve successfull service start with
dotnet publish "MyProject.csproj" -c Release -o D:\publish --self-contained --runtime linux-x64
and saw in logs a message about invalid .dll.
Then I correct the .dll and tried to publish self-contained and framework-dependent — both started successfully.
So reason may be tricky.
After some googleing I found this:
https://github.com/aspnet/aspnet-docker/issues/301
I'm not certain what caused it but it seems to have gone away. It's probably because I had a case mismatch of appSettings.json instead of appsettings.json which meant that the file was not being loaded. Terrible error though.
In my case it was that I had forgot to put appsettings.json to copy on builds.
Hope this helps someone else and get's higher on google searches.