hostpolicy.dll not found for custom DotnetCliTool
See original GitHub issueSteps 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:
- Created 7 years ago
- Comments:9 (4 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ctaggart I found the issue. The nupkg for
dotnet-sourcelink
does not include the app’sruntimeconfig.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!
Thank @piotrpMSFT. This was a very frustrating issue because of the ambiguous error message. Did a
dotnet pack
and the runtimeconfigs file was there.