由于 testhost.dll,Azure-DevOps Pipeline 失败

use*_*834 6 testing xunit azure-devops

我的 azure devops 测试管道遇到一些问题。我正在使用 xunit 测试,并且每个测试项目都正确运行,并且我可以查看测试结果,但管道由于以下错误而失败

##[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.
Run Code Online (Sandbox Code Playgroud)

就像这里建议的那样,我添加了一个额外的过滤器,所以testhost.dll我的 yaml-snippet 看起来像这样:

- 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
Run Code Online (Sandbox Code Playgroud)

但是,错误仍然发生,并且我的构建被标记为失败。我怎样才能解决这个问题?

Sim*_*ess 1

这个GitHub 问题有望有所帮助。

值得尝试的事情:

  • 删除从一个测试组件到另一测试组件的引用
  • 将 Microsoft.NET.Test.SDK 更新到 16.6.1
  • 添加 application.runtimeconfig.json 文件

希望这可以帮助!