Sdk: libhostpolicy.so not found when cross-compiling for Linux on Windows

Created on 1 May 2017  路  6Comments  路  Source: dotnet/sdk

Steps to reproduce

Create new ASP.NET Core 1.1 web app in Visual Studio 2017, using the "empty" template
Build and publish for Debian:

dotnet restore -r debian-x64
dotnet publish . -o "C:\TempPublish\helloworld" -c Release -r debian-x64

rsync to Debian server
Attempt to run the site:

ASPNETCORE_ENVIRONMENT=Production COREHOST_TRACE=1 dotnet WebApplication9.dll

Expected behavior

It works

Actual behavior

A fatal error was encountered. The library 'libhostpolicy.so' required to execute the application was not found

I do see libhostpolicy.so at /opt/dotnet/shared/Microsoft.NETCore.App/1.1.1/libhostpolicy.so; is there something I need to do to get it to use that one?

Full error:

18:40 daniel@vps03 /home/daniel/temp/corehelloworld/helloworld
% ASPNETCORE_ENVIRONMENT=Production COREHOST_TRACE=1 dotnet WebApplication9.dll  --server.urls http://\*:37652
Tracing enabled
--- Invoked dotnet [version: 1.1.0, commit hash: 928f77c4bc3f49d892459992fb6e1d5542cb5e86] main = {
dotnet
WebApplication9.dll
--server.urls
http://*:37652
}
Reading fx resolver directory=[/opt/dotnet/host/fxr]
Considering fxr version=[.]...
Considering fxr version=[1.1.0]...
Considering fxr version=[..]...
Detected latest fxr version=[/opt/dotnet/host/fxr/1.1.0]...
Resolved fxr [/opt/dotnet/host/fxr/1.1.0/libhostfxr.so]...
Tracing enabled
--- Invoked hostfxr [commit hash: 928f77c4bc3f49d892459992fb6e1d5542cb5e86] main
Own DLL path=[/opt/dotnet/dotnet.dll]
Checking if CoreCLR path exists=[/opt/dotnet/libcoreclr.so]
--- Executing in muxer mode...
Detected a non-standalone application, expecting app.dll to execute.
Treating application '/home/daniel/temp/corehelloworld/helloworld/WebApplication9.dll' as a managed executable.
App runtimeconfig.json from [/home/daniel/temp/corehelloworld/helloworld/WebApplication9.dll]
Runtime config is cfg=/home/daniel/temp/corehelloworld/helloworld/WebApplication9.runtimeconfig.json dev=/home/daniel/temp/corehelloworld/helloworld/WebApplication9.runtimeconfig.dev.json
Attempting to read runtime config: /home/daniel/temp/corehelloworld/helloworld/WebApplication9.runtimeconfig.json
Attempting to read dev runtime config: /home/daniel/temp/corehelloworld/helloworld/WebApplication9.runtimeconfig.dev.json
Runtime config [/home/daniel/temp/corehelloworld/helloworld/WebApplication9.runtimeconfig.json] is valid=[1]
Executing as a standalone app as per config file [/home/daniel/temp/corehelloworld/helloworld/WebApplication9.runtimeconfig.json]
--- Resolving libhostpolicy.so version from deps json [/home/daniel/temp/corehelloworld/helloworld/WebApplication9.deps.json]
Resolved version 1.1.0 from dependency manifest file [/home/daniel/temp/corehelloworld/helloworld/WebApplication9.deps.json]
Directory core servicing at [] was not specified or found
Fallback directory core servicing at [/opt/coreservicing] was not found
Did not find libhostpolicy.so in directory /pkgs/runtime.debian.8-x64.Microsoft.NETCore.DotNetHostPolicy/1.1.0/runtimes/debian.8-x64/native
The expected libhostpolicy.so directory is [/home/daniel/temp/corehelloworld/helloworld]
The libhostpolicy.so was not found in [/home/daniel/temp/corehelloworld/helloworld]
A fatal error was encountered. The library 'libhostpolicy.so' required to execute the application was not found in '/home/daniel/temp/corehelloworld/helloworld'.

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0)

Product Information:
 Version:            1.0.0
 Commit SHA-1 hash:  e53429feb4

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.16179
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.0

Server has:

Microsoft .NET Core Shared Framework Host

  Version  : 1.1.0
  Build    : 928f77c4bc3f49d892459992fb6e1d5542cb5e86

Most helpful comment

A couple of things here.

  1. The right rid to use with debian is debian.8-x64, not debian-x64.
  2. Second, taking in consideration the folder you put above, you need to check under bin/Release/netcoreapp1.1/debian-x64/publish/. I know the the output of the publish is pointing to the folder above, we have fixed that in the 2.0 tooling.

I have tried what I indicated above and I can see a file in the publish output folder and run it.

All 6 comments

When you publish your app using a runtime, it becomes a self-contained app. In order to run a self-contained app, you don't execute it with dotnet . You run it by executing that should be available in the publish folder.

You use dotnet for portable apps (no runtime identifier).

Can you give that a go?

You run it by executing that should be available in the publish folder.

I'm getting a .dll file when I publish the site. How do I execute it?

You should also be getting an executable named after your application in the publish folder. Can you maybe share the contents of your published output?

@livarcocc Here's a full directory listing of the publish folder after publishing a site called WebApplication12:

2016-10-31  03:32 PM           499,051 libuv.so
2017-01-20  05:27 PM            59,176 Microsoft.ApplicationInsights.AspNetCore.dll
2016-12-06  04:09 PM           148,728 Microsoft.ApplicationInsights.dll
2017-02-17  06:01 PM            16,896 Microsoft.AspNetCore.Diagnostics.Abstractions.dll
2017-02-17  06:01 PM           262,144 Microsoft.AspNetCore.Diagnostics.dll
2017-02-17  06:01 PM            19,968 Microsoft.AspNetCore.Hosting.Abstractions.dll
2017-02-17  06:01 PM           109,560 Microsoft.AspNetCore.Hosting.dll
2017-02-17  06:01 PM            15,360 Microsoft.AspNetCore.Hosting.Server.Abstractions.dll
2017-02-17  06:01 PM            66,560 Microsoft.AspNetCore.Http.Abstractions.dll
2017-02-17  06:01 PM            80,384 Microsoft.AspNetCore.Http.dll
2017-02-17  06:01 PM            38,912 Microsoft.AspNetCore.Http.Extensions.dll
2017-02-17  06:01 PM            30,720 Microsoft.AspNetCore.Http.Features.dll
2017-02-17  06:01 PM            28,160 Microsoft.AspNetCore.HttpOverrides.dll
2017-02-17  06:01 PM            36,856 Microsoft.AspNetCore.Routing.Abstractions.dll
2017-02-17  06:01 PM           106,488 Microsoft.AspNetCore.Routing.dll
2017-02-17  06:01 PM            28,664 Microsoft.AspNetCore.Server.IISIntegration.dll
2017-02-17  06:01 PM           281,088 Microsoft.AspNetCore.Server.Kestrel.dll
2017-02-17  06:01 PM            72,704 Microsoft.AspNetCore.WebUtilities.dll
2016-06-13  05:31 AM         4,211,112 Microsoft.CodeAnalysis.CSharp.dll
2016-06-13  05:31 AM         2,049,432 Microsoft.CodeAnalysis.dll
2016-06-13  05:31 AM         5,061,040 Microsoft.CodeAnalysis.VisualBasic.dll
2016-11-05  04:55 AM           450,248 Microsoft.CSharp.dll
2017-02-17  06:01 PM            19,968 Microsoft.Extensions.Configuration.Abstractions.dll
2017-02-17  06:01 PM            23,552 Microsoft.Extensions.Configuration.Binder.dll
2017-02-17  06:01 PM            24,576 Microsoft.Extensions.Configuration.dll
2017-02-17  06:01 PM            19,968 Microsoft.Extensions.Configuration.EnvironmentVariables.dll
2017-02-17  06:01 PM            22,520 Microsoft.Extensions.Configuration.FileExtensions.dll
2017-02-17  06:01 PM            23,552 Microsoft.Extensions.Configuration.Json.dll
2016-11-14  09:41 PM            35,320 Microsoft.Extensions.DependencyInjection.Abstractions.dll
2016-11-14  09:41 PM            45,048 Microsoft.Extensions.DependencyInjection.dll
2016-06-22  09:14 AM            37,880 Microsoft.Extensions.DiagnosticAdapter.dll
2016-11-14  09:41 PM            18,944 Microsoft.Extensions.FileProviders.Abstractions.dll
2016-11-14  09:41 PM            31,736 Microsoft.Extensions.FileProviders.Physical.dll
2016-11-14  09:41 PM            39,424 Microsoft.Extensions.FileSystemGlobbing.dll
2017-02-17  06:01 PM            44,032 Microsoft.Extensions.Logging.Abstractions.dll
2017-02-17  06:01 PM            27,648 Microsoft.Extensions.Logging.Console.dll
2017-02-17  06:01 PM            18,432 Microsoft.Extensions.Logging.dll
2016-11-14  09:41 PM            17,920 Microsoft.Extensions.ObjectPool.dll
2017-02-17  06:01 PM            15,872 Microsoft.Extensions.Options.ConfigurationExtensions.dll
2017-02-17  06:01 PM            22,016 Microsoft.Extensions.Options.dll
2016-11-14  09:41 PM            16,376 Microsoft.Extensions.PlatformAbstractions.dll
2016-11-14  09:41 PM            29,176 Microsoft.Extensions.Primitives.dll
2017-02-17  06:01 PM            66,560 Microsoft.Net.Http.Headers.dll
2016-11-05  04:55 AM           188,120 Microsoft.VisualBasic.dll
2016-11-05  04:55 AM            25,992 Microsoft.Win32.Primitives.dll
2016-11-05  04:55 AM            39,816 Microsoft.Win32.Registry.dll
2016-06-13  11:06 PM           468,480 Newtonsoft.Json.dll
2017-05-02  09:53 PM    <DIR>          refs
2016-11-05  04:55 AM            21,856 System.AppContext.dll
2016-11-05  04:55 AM            27,320 System.Buffers.dll
2016-11-05  04:55 AM            93,432 System.Collections.Concurrent.dll
2016-11-05  04:55 AM            98,504 System.Collections.dll
2016-11-05  04:55 AM           180,984 System.Collections.Immutable.dll
2016-11-05  04:55 AM            88,472 System.Collections.NonGeneric.dll
2016-11-05  04:55 AM            45,984 System.Collections.Specialized.dll
2016-11-05  04:55 AM            83,368 System.ComponentModel.Annotations.dll
2016-11-05  04:55 AM            21,720 System.ComponentModel.dll
2016-11-05  04:55 AM            36,256 System.ComponentModel.Primitives.dll
2016-11-05  04:55 AM           121,776 System.ComponentModel.TypeConverter.dll
2016-11-05  04:55 AM            93,528 System.Console.dll
2016-11-05  04:55 AM            22,936 System.Diagnostics.Contracts.dll
2016-11-05  04:55 AM            40,832 System.Diagnostics.Debug.dll
2016-11-05  04:55 AM            35,760 System.Diagnostics.DiagnosticSource.dll
2016-06-11  11:13 PM            28,584 System.Diagnostics.FileVersionInfo.dll
2016-11-05  04:55 AM            88,808 System.Diagnostics.Process.dll
2016-11-05  04:55 AM            26,520 System.Diagnostics.StackTrace.dll
2016-11-05  04:55 AM            22,400 System.Diagnostics.Tools.dll
2016-11-05  04:55 AM            37,264 System.Diagnostics.Tracing.dll
2016-11-05  04:56 AM           114,392 System.Dynamic.Runtime.dll
2016-11-05  04:55 AM            23,448 System.Globalization.Calendars.dll
2016-11-05  04:56 AM            22,384 System.Globalization.dll
2016-11-05  04:56 AM            31,136 System.Globalization.Extensions.dll
2016-11-05  04:56 AM           117,624 System.IO.Compression.dll
2016-11-05  04:56 AM            29,592 System.IO.Compression.ZipFile.dll
2016-11-05  04:56 AM            39,232 System.IO.dll
2016-11-05  04:56 AM            98,160 System.IO.FileSystem.dll
2016-11-05  04:56 AM            22,432 System.IO.FileSystem.Primitives.dll
2016-11-05  04:56 AM            55,024 System.IO.FileSystem.Watcher.dll
2016-11-05  04:56 AM            49,552 System.IO.MemoryMappedFiles.dll
2016-11-05  04:56 AM            45,472 System.IO.UnmanagedMemoryStream.dll
2016-11-05  04:56 AM           128,840 System.Linq.dll
2016-11-05  04:56 AM           458,104 System.Linq.Expressions.dll
2016-11-05  04:56 AM           224,976 System.Linq.Parallel.dll
2016-11-05  04:56 AM            69,848 System.Linq.Queryable.dll
2016-11-05  04:56 AM           287,576 System.Net.Http.dll
2016-11-05  04:56 AM            68,488 System.Net.NameResolution.dll
2016-11-05  04:56 AM           309,104 System.Net.Primitives.dll
2016-11-05  04:56 AM            55,664 System.Net.Requests.dll
2016-11-05  04:56 AM           227,696 System.Net.Security.dll
2016-11-05  04:56 AM           221,032 System.Net.Sockets.dll
2016-11-05  04:56 AM            32,504 System.Net.WebHeaderCollection.dll
2016-11-05  04:56 AM            30,584 System.Net.WebSockets.dll
2016-11-05  04:56 AM           158,080 System.Numerics.Vectors.dll
2016-11-05  04:56 AM            49,352 System.ObjectModel.dll
2016-11-05  04:56 AM           125,800 System.Private.Uri.dll
2016-11-05  04:56 AM            42,400 System.Reflection.DispatchProxy.dll
2016-11-05  04:56 AM            22,880 System.Reflection.dll
2016-11-05  04:56 AM            22,392 System.Reflection.Emit.dll
2016-11-05  04:56 AM            22,960 System.Reflection.Emit.ILGeneration.dll
2016-11-05  04:56 AM            22,952 System.Reflection.Emit.Lightweight.dll
2016-11-05  04:56 AM            24,816 System.Reflection.Extensions.dll
2016-11-05  04:56 AM           452,840 System.Reflection.Metadata.dll
2016-11-05  04:56 AM            22,256 System.Reflection.Primitives.dll
2016-11-05  04:56 AM            29,600 System.Reflection.TypeExtensions.dll
2016-11-05  04:56 AM            32,992 System.Resources.Reader.dll
2016-11-05  04:56 AM            22,784 System.Resources.ResourceManager.dll
2016-11-05  04:56 AM            20,768 System.Runtime.CompilerServices.Unsafe.dll
2016-11-05  04:57 AM            39,768 System.Runtime.dll
2016-11-05  04:56 AM            75,648 System.Runtime.Extensions.dll
2016-11-05  04:56 AM            22,904 System.Runtime.Handles.dll
2016-11-05  04:56 AM            34,200 System.Runtime.InteropServices.dll
2016-11-05  04:57 AM            27,616 System.Runtime.InteropServices.RuntimeInformation.dll
2016-11-05  04:57 AM            22,232 System.Runtime.Loader.dll
2016-11-05  04:57 AM            71,392 System.Runtime.Numerics.dll
2016-11-05  04:57 AM            29,632 System.Runtime.Serialization.Primitives.dll
2016-11-05  04:57 AM            57,720 System.Security.Claims.dll
2016-11-05  04:57 AM            92,608 System.Security.Cryptography.Algorithms.dll
2016-11-05  04:57 AM            31,136 System.Security.Cryptography.Cng.dll
2016-11-05  04:57 AM            24,992 System.Security.Cryptography.Csp.dll
2016-11-05  04:57 AM            47,032 System.Security.Cryptography.Encoding.dll
2016-11-05  04:57 AM            56,240 System.Security.Cryptography.OpenSsl.dll
2016-11-05  04:57 AM            45,504 System.Security.Cryptography.Primitives.dll
2016-11-05  04:57 AM           164,312 System.Security.Cryptography.X509Certificates.dll
2016-11-05  04:57 AM            21,736 System.Security.Principal.dll
2016-11-05  04:57 AM            29,608 System.Security.Principal.Windows.dll
2016-06-11  11:14 PM           759,712 System.Text.Encoding.CodePages.dll
2016-11-05  04:57 AM            22,384 System.Text.Encoding.dll
2016-11-05  04:57 AM            22,944 System.Text.Encoding.Extensions.dll
2016-11-05  04:57 AM            64,232 System.Text.Encodings.Web.dll
2016-11-05  04:57 AM           113,912 System.Text.RegularExpressions.dll
2016-11-05  04:57 AM            50,016 System.Threading.dll
2016-11-05  04:57 AM            23,440 System.Threading.Overlapped.dll
2016-11-05  04:57 AM           179,104 System.Threading.Tasks.Dataflow.dll
2016-11-05  04:57 AM            26,488 System.Threading.Tasks.dll
2016-11-05  04:57 AM            25,864 System.Threading.Tasks.Extensions.dll
2016-11-05  04:57 AM            58,112 System.Threading.Tasks.Parallel.dll
2016-11-05  04:57 AM            22,400 System.Threading.Thread.dll
2016-11-05  04:57 AM            22,416 System.Threading.ThreadPool.dll
2016-11-05  04:57 AM            22,392 System.Threading.Timer.dll
2016-11-05  04:57 AM           606,592 System.Xml.ReaderWriter.dll
2016-11-05  04:57 AM           111,312 System.Xml.XDocument.dll
2016-06-11  11:15 PM           138,104 System.Xml.XmlDocument.dll
2016-06-11  11:15 PM           187,744 System.Xml.XPath.dll
2016-06-11  11:15 PM            36,744 System.Xml.XPath.XDocument.dll
2017-05-02  09:53 PM               371 web.config
2017-05-02  09:53 PM           255,398 WebApplication12.deps.json
2017-05-02  09:53 PM             7,168 WebApplication12.dll
2017-05-02  09:53 PM               956 WebApplication12.pdb
2017-05-02  09:53 PM                98 WebApplication12.runtimeconfig.json

I checked bin\Release\netcoreapp1.1\debian-x64\ and it also doesn't contain an executable.

A couple of things here.

  1. The right rid to use with debian is debian.8-x64, not debian-x64.
  2. Second, taking in consideration the folder you put above, you need to check under bin/Release/netcoreapp1.1/debian-x64/publish/. I know the the output of the publish is pointing to the folder above, we have fixed that in the 2.0 tooling.

I have tried what I indicated above and I can see a file in the publish output folder and run it.

Thank you! It works when I use debian.8-x64. Did that change at some point? debian-x64 worked in previous releases.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

natemcmaster picture natemcmaster  路  3Comments

gkhanna79 picture gkhanna79  路  3Comments

thomaslevesque picture thomaslevesque  路  3Comments

joffreykern picture joffreykern  路  3Comments

srayuws picture srayuws  路  3Comments