Azure-DevOps Pipeline fails because of testhost.dll
Asked Answered
A

1

6

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?

Ariana answered 29/5, 2020 at 16:52 Comment(1)
Is there a way to exclude testhost.dll for testSelector: testPlan instead of testSelector:testAssembliesAutocephalous
P
1

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!

Panel answered 30/5, 2020 at 10:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.