We wanted to run integration tests in VSTS’ release phase. Our application is ASP.NET Core 2.0 based and the integration tests are on .NET Core 2.0 projects. Unfortunately we were always met with the following error:

Testhost process exited with error: A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'D:\a\r1\a\IntegrationTests\'.

It turned out that the problem was that we were publishing integration tests in the build phase without providing the framework and runtime arguments. We had to provide both of these arguments to the publish command to get things working:

-c $(BuildConfiguration) -o $(Build.ArtifactStagingDirectory) -r "win10-x64" -f "netcoreapp2.0"