【发布时间】:2020-05-25 18:28:48
【问题描述】:
在 Azure DevOps Pipelines 中运行单元测试时收到以下错误:
##[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.
##[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'.
在我的构建管道中,我有 6 个 .NetCore xunit 测试项目和 1 个 .net 标准 xunit 项目。
我正在尝试在发布到我的组织提要之前执行所有单元测试。
我试图排除 testhost.dll 像其他人一样被 VsTest 选中,并且 成功,但对我来说似乎不起作用..
我的 VSTest 任务配置:
- task: VSTest@2
displayName: 'Running Tests NETFramework'
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: |
General\Exceptions.Handling.Tests\bin\Release\Exceptions.Handling.Tests.dll
!*testhost.dll
!**\*testhost.dll
!**\obj\**
!**\xunit.runner.visualstudio.testadapter.dll
!**\xunit.runner.visualstudio.dotnetcore.testadapter.dll
searchFolder: './tests/UnitTests'
platform: '$(buildPlatform)'
configuration: '$(configuration)'
- task: VSTest@2
displayName: 'Running Tests Framework:.NETCoreApp,Version=v3.1'
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: |
**\*Tests.dll
!*testhost.dll
!**\*testhost.dll
!**\*Exceptions.Handling.Tests.dll
!**\obj\**
!**\xunit.runner.visualstudio.testadapter.dll
!**\xunit.runner.visualstudio.dotnetcore.testadapter.dll
searchFolder: './tests/UnitTests'
otherConsoleOptions: '/Framework:.NETCoreApp,Version=v3.1 /logger:console;verbosity="normal"'
platform: '$(buildPlatform)'
configuration: '$(configuration)'
【问题讨论】:
标签: azure-devops azure-pipelines xunit