Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find hostpolicy.dll #2427

Closed
nohwnd opened this issue May 7, 2020 · 1 comment
Closed

Could not find hostpolicy.dll #2427

nohwnd opened this issue May 7, 2020 · 1 comment

Comments

@nohwnd
Copy link
Member

nohwnd commented May 7, 2020

I am encountering this error:

Testhost process exited with error: A fatal error was encountered. The library 
'hostpolicy.dll' required to execute the application was not found in '<project>'.
Failed to run as a self-contained app. If this should be a 
framework-dependent app, add the <project>\testhost.runtimeconfig.json 
file specifying the appropriate framework.
@nohwnd
Copy link
Member Author

nohwnd commented May 7, 2020

Using RuntimeIdentifier and OutputType Exe on netcoreapp3.1 (and newer) will make the build basically publish the project. This will add the runtime to the result directory and change the runtimeconfig.json to point to the local copy of the runtime.

// in your .csproj
<OutputType>Exe</OutputType>
<RuntimeIdentifiers>osx.10.11-x64;osx.10.12-x64;win7-x64;win10-x64</RuntimeIdentifiers>

When executing tests, testhost.exe is loaded from a different location (nuget folder), but using the same runtimeconfig.json as the test project, and will fail to find the hostpolicy, because it only looks next to the executable, where there is no hostpolicy.dll.

The solution here is to copy the testhost.exe next to the project and invoke it from there, which was fixed early in 16.6.0. Please update your Microsoft.NET.Test.Sdk nuget package to 16.6.1

fix commit: 3726dae

Related issue with this problem in general, not just vstest:
dotnet/runtime#3569

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant