question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

hostpolicy.dll not found for custom DotnetCliTool

See original GitHub issue

Steps to reproduce

git clone https://github.com/ctaggart/sourcelink-test --single-branch --branch hostpolicy
cd sourcelink-test\src\ClassLibrary1
dotnet restore
dotnet sourcelink

Expected behavior

I get the same output as when running dotnet run when building the custom DotnetCliTool:

PS C:\Users\camer\cs\SourceLink\dotnet-sourcelink> dotnet run
SourceLink: Source Code On Demand

Usage: dotnet sourcelink [options] [command]

Options:
  -h|--help  Show help information

Commands:
  print-json  print the Source Link JSON stored in the Portable PDB file

Use "dotnet sourcelink [command] --help" for more information about a command.

Actual behavior

PS C:\Users\camer\cs\sourcelink-test\src\ClassLibrary1> dotnet sourcelink
A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\Users\camer\.nuget\packages\.tools\dotnet-sourcelink\2.0.0-b318\netc
oreapp1.0'.

Environment data

dotnet --info output:

PS C:\Users\camer\cs\sourcelink-test\src\ClassLibrary1> dotnet --info
.NET Command Line Tools (1.0.0-rc3-004530)

Product Information:
 Version:            1.0.0-rc3-004530
 Commit SHA-1 hash:  0de3338607

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

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
TheRealPiotrPcommented, Feb 6, 2017

@ctaggart I found the issue. The nupkg for dotnet-sourcelink does not include the app’s runtimeconfig.json file. As a result, it’s not a valid tool. I fixed this for my local repro by copying another app’s runtimeconfig.json next to the app.dll, changing file names to match.

Take a look at @blackdwarf’s great explanation here which includes a csproj snippet that causes the runtimeconfig.json to be included!

1reaction
jroux-gitcommented, Feb 13, 2017

Thank @piotrpMSFT. This was a very frustrating issue because of the ambiguous error message. Did a dotnet pack and the runtimeconfigs file was there.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The library hostpolicy.dll was not found
2. I ran into this error when trying to run a custom DotnetCliTool with Visual Studio 2017 RC3 that was missing a runtimeconfig....
Read more >
hostpolicy.dll not found for custom DotnetCliTool #7685
@ctaggart I found the issue. The nupkg for dotnet-sourcelink does not include the app's runtimeconfig.json file. As a result, it's not a valid ......
Read more >
The library hostpolicy.dll was not found - Doc
I ran into this error when trying to run a custom DotnetCliTool with Visual Studio 2017 RC3 that was missing a runtimeconfig.json. The...
Read more >
The library 'hostpolicy.dll' required to execute ...
dll ' required to execute the application was not found in 'C:\Program Files\dotnet'. In my build pipeline I have 6 .NetCore xunit test...
Read more >
Rider/Azure: hostpolicy.dll not found
Functions.dll A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'Y:\RiderProjects ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found