Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The library hostpolicy.dll was not found

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?

like image 567
Nate Barbettini Avatar asked Jun 28 '16 20:06

Nate Barbettini


Video Answer


1 Answers

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.

like image 166
Soleil Avatar answered Oct 05 '22 08:10

Soleil