Azure 管道任务 VSTest@2 因错误而失败 - 无法加载文件或程序集 'Microsoft.VisualStudio.TestPlatform.Common.resources'

Azure pipelines task VSTest@2 failing with error - Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.Common.resources'

我创建了 .Net Core 3.1 API 测试用例项目。我的项目有以下金块包。

  • Microsoft.NET.Test.Sdk 15.3.0
  • Moq 4.16.1
  • xunit - 2.4.1
  • xunit.runner.visualstudio - 2.4.3

单元测试项目在VS 2019中正常执行,我所有的测试用例都通过了。在部署 yaml 文件中,我有以下代码。

- task: VSTest@2
 - inputs:
     platform: '$(buildPlatform)'
     configuration: '$(buildConfiguration)'

此任务因大量错误而失败

2021-03-03T18:33:16.4990294Z [MSTest][Discovery][D:\a\s\API\MyProject.ApiTests\bin\Release\netcoreapp3.1\cs\Microsoft.VisualStudio.TestPlatform.Common.resources.dll] Failed to discover tests from assembly D:\a\s\API\MyProject.ApiTests\bin\Release\netcoreapp3.1\cs\Microsoft.VisualStudio.TestPlatform.Common.resources.dll. Reason:Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.Common.resources' or one of its dependencies. The system cannot find the file specified.
2021-03-03T18:33:16.5032225Z [MSTest][Discovery][D:\a\s\API\MyProject.ApiTests\bin\Release\netcoreapp3.1\cs\Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll] Failed to discover tests from assembly D:\a\s\API\MyProject.ApiTests\bin\Release\netcoreapp3.1\cs\Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll. Reason:Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.ObjectModel.resources' or one of its dependencies. The system cannot find the file specified.
2021-03-03T18:33:16.5033961Z [MSTest][Discovery][D:\a\s\API\MyProject.ApiTests\bin\Release\netcoreapp3.1\de\Microsoft.TestPlatform.CommunicationUtilities.resources.dll] Failed to discover tests from assembly D:\a\s\API\MyProject.ApiTests\bin\Release\netcoreapp3.1\de\Microsoft.TestPlatform.CommunicationUtilities.resources.dll. Reason:Could not load file or assembly 'Microsoft.TestPlatform.CommunicationUtilities.resources' or one of its dependencies. The system cannot find the file specified.

等等。

我尝试了 upgrading/downgrading Microsoft.NET.Test.Sdk 个版本,但没有成功。任何帮助将不胜感激。

在我们的项目中,我们做了几件事:确保安装了正确的工具集,并具体说明测试路径:

          - task: VisualStudioTestPlatformInstaller@1
            displayName: 'Install Visual Studio Test Platform'
            inputs:
              packageFeedSelector: 'nugetOrg'
              versionSelector: 'latestStable'
          - task: VSTest@2
            displayName: 'Run Unit Tests'
            inputs:
              vsTestVersion: 'toolsInstaller'    
              # our test projects all have ".Tests" in the name
              testAssemblyVer2: '**/bin/$(buildConfiguration)/*.Tests.dll'
              platform: '$(buildPlatform)'
              configuration: '$(buildConfiguration)'
              codeCoverageEnabled: true
              runTestsInIsolation: true

WaitingForGuacamole 的上述回答与 Microsoft.NET.Test.Sdk 到 16.9.1 的升级一起工作。谢谢。