找不到执行应用程序所需的库'hostpolicy.dll'



我在 Azure DevOps 管道中运行单元测试时收到以下错误:

##[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 Filesdotnet'. ##[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 Filesdotnet'.  

在我的构建管道中,我有 6 个.NetCore xunit 测试项目和 1 个 .net 标准 xunit 项目。

我正在尝试在发布到我的组织提要之前执行所有单元测试。

我试图排除测试主机.dll像其他人一样被 VsTest 选中,并且 成功,但对我来说似乎不起作用..

我的 VSTest 任务配置:

- task: VSTest@2
displayName: 'Running Tests NETFramework'
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: |
GeneralExceptions.Handling.TestsbinReleaseExceptions.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)'

正确阅读日志后,我发现 VsTest 任务正在选择以下 dll:Xamarin.Forms.Core.UnitTests.dll、Xamarin.Forms.Xaml.UnitTests.dll。

我所要做的就是将搜索模式从***Tests.dll更改为***.Tests.dll,因为我所有的单元测试项目都遵循以下约定:Org.Base.Project.Tests.

最新更新