The library hostpolicy.dll was not found

failed to run as a self-contained app. if this should be a framework-dependent app
dotnet/core-setup#6189
dotnet publish
multiple runtimeconfig json files present
invalid runtimeconfig json
net core
emitentrypoint
net core clickonce

I have a simple .NET Core project (console app) that I'm trying to compile and run. dotnet build succeeds, but I get the following error when I do dotnet run:

λ dotnet run
Project RazorPrecompiler (.NETCoreApp,Version=v1.0) was previously compiled. Skipping compilation.
A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in [path].

My project.json looks like this:

{
  "buildOptions": {
    "warningsAsErrors": true
  },
  "dependencies": {
    "Microsoft.AspNetCore.Razor": "1.0.0",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0"
    }
  },
  "description": "Precompiles Razor views.",
  "frameworks": {
    "netcoreapp1.0": {
      "imports": [ ]
    }
  },
  "version": "1.2.0"
}

What is hostpolicy.dll, and why is it missing?


Update for dotnet core 2.0 and beyond: the file appname.runtimeconfig.json (for both debug and release configuration) is needed in the same path as appname.dll.

It contains:

{
  "runtimeOptions": {
    "tfm": "netcoreapp2.0",
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "2.0.0"
    }
  }
}

then dotnet.exe exec "path/to/appname.dll" [appargs] works.

dotnet exec with fx project got error `The library 'hostpolicy.dll , The library 'hostpolicy.dll' required to execute the application was not found in NET Framework it's missing some required files to run on . I have a simple .NET Core project (console app) that I'm trying to compile and run. dotnet build succeeds, but I get the following error when I do dotnet run: λ


This error message is unhelpful. The actual problem is a missing emitEntryPoint property:

  "buildOptions": {
    ...
    "emitEntryPoint": true
  },

Once this is added, the compiler will let you know about any other problems (like a missing static void Main() method). Successfully compiling the project will result in an output that dotnet run can execute.

The library hostpolicy.dll was not found, Update for dotnet core 2.0 and beyond: the file appname.runtimeconfig.json (for both debug and release configuration) is needed in the same  The library 'hostpolicy.dll' required to execute the application was not found in 'some path'. It hit me several times and I've spent some time just looking for that dll and why it is missing until I found that other people also hit it and the reason was something else.


For me it was a stupid mistake: I started a wrong file.

Fixing “The library 'hostpolicy.dll' required to execute the application , Here's one way to fix "the library 'hostpolicy.dll' required to execute the application was not found". The library 'hostpolicy.dll' required to execute the application was not found in 'D:\\BenchmarkingApp\\BenchmarkingApp\\bin\\Debug\ etcoreapp2.1\\'.\r\nFailed to run as a self-contained app. If this should be a framework-dependent app, add the D:\\BenchmarkingApp\\BenchmarkingApp\\bin\\Debug\ etcoreapp2.1\\BenchmarkingApp.runtimeconfig.json file specifying the appropriate framework.\r "


For me the issue was with the version mismatch. I had a different ".Net core SDK" version installed and a different version was specified in .json file.

Once I modified the version in my .json file the application started working fine.

EF Core fails to load hostpolicy.dll when RuntimeIdentifier is win-x86 , Failed to load the dll from [runtimepath]\win-x86\hostpolicy.dll], HRESULT: occurred while loading required library hostpolicy.dll from [runtimepath]\win-x86\] Nowadays he's not only working on SharePoint, but also on . The library 'libhostpolicy.so' required to execute the application was not found in '/app'. docker.net The library 'hostpolicy.dll' required to execute the


In my case it was because I was publishing a self-contained application for the wrong target. My intent was to run on alpine linux, but I was building for libc when I should have been building for musl.

The failing package was built using:

dotnet publish --self-contained true --runtime linux-x64 --framework netcoreapp2.1 --output /app

Changing the RID:

dotnet publish --self-contained true --runtime linux-musl-x64 --framework netcoreapp2.1 --output /app

produced a functional package. Notice the RID changed from linux-x64 to linux-musl-x64. If I had read the .NET Core RID Catalog page this could have been avoided. 😅

'dotnet' command fails expecting hostpolicy.dll to be present, "Expect required library hostpolicy.dll to be present in [C:\Temp\AzureHapp] - This may be because of an invalid .NET Core FX configuration in  Similar question The library hostpolicy.dll was not found – Michael Freidgeim Oct 29 '17 at 12:27


Azure DevOps requests hostpolicy.dll during tests, The library 'hostpolicy.dll' required to execute the application was not found in 'C:\​agent\_work\4\s\Query.Core.Tests\bin\netcoreapp2.2\'. Not sure if I did something weird to my workspace, but I also found that I had .dll in both obj and bin directories. I was in obj , and realized that the one in bin had this .runtimeconfig.json file already.


Dot Net (Core), The library 'hostpolicy.dll' required to execute the application was not found in [​path]. My project.json looks like this: {; "buildOptions": {; "warningsAsErrors": true; }  The library 'libhostpolicy.so' required to execute the application was not found in '/app'. The container runs fine when being run using Visual Studio's Docker Support project. It only throws the above error when running on Docker for AWS which uses Moby linux for the host OS. I get no further information than that unfortunately.


The library 'hostpolicy.dll' required to execute the , The library 'hostpolicy.dll' required to execute the application was not found in 'C:\​Program Files\dotnet\shared\Microsoft.AspNetCore.App\2.1.0-preview1-final'. The library 'hostpolicy.dll' required to execute the application was not found in 'F:\DotNetTest\DependencyTest\bin\Debug etcoreapp2.0\'. Notes When initially designing .NET Core for MSBuild, we wanted the experience that "framework-dependent vs. self-contained was a publish time decision".