user3079834
user3079834

Reputation: 2214

Azure-DevOps Pipeline fails because of testhost.dll

I'm having some troubles with my azure devops testing-pipeline. I'm using xunit tests and every test-project runs correctly and I can view the test results, but the pipeline fails anyway because of the following error

##[error]Testhost process exited with error: A fatal error was encountered. The library 'hostpolicy.dll' required to execute the application was not found in 'C:\Program Files\dotnet'.
##[error]. Please check the diagnostic logs for more information.

Like suggested here, I added an additional filter for testhost.dll so my yaml-snippet looks like this:

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'
    testSelector: 'testAssemblies'
    testAssemblyVer2: |
      **\*test.dll
      !**\*TestAdapter.dll
      !**\obj\**
      !**\testhost.dll
      !*testhost.dll
    searchFolder: '$(System.DefaultWorkingDirectory)'
    diagnosticsEnabled: true
    codeCoverageEnabled: true

However, the error still occurs and my Build is marked as failed. How can I fix this?

Upvotes: 6

Views: 5058

Answers (1)

Simon Ness
Simon Ness

Reputation: 2550

This GitHub issue should hopefully help.

Things to try:

  • remove references from one test assembly to another
  • update Microsoft.NET.Test.SDK to 16.6.1
  • add an application.runtimeconfig.json file

Hope this helps!

Upvotes: 1

Related Questions