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

The library 'hostpolicy.dll' required to execute the application was not found

我在 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)'

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

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