如何解决Azure 管道任务 VSTest@2 因错误而失败 - 无法加载文件或程序集“Microsoft.VisualStudio.TestPlatform.Common.resources”
我创建了 .Net Core 3.1 API 测试用例项目。我的项目有以下 nugget 包。
- Microsoft.NET.Test.Sdk 15.3.0
- 最小起订量 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\1\s\API\MyProject.ApiTests\bin\Release\netcoreapp3.1\cs\Microsoft.VisualStudio.TestPlatform.Common.resources.dll] Failed to discover tests from assembly D:\a\1\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\1\s\API\MyProject.ApiTests\bin\Release\netcoreapp3.1\cs\Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll] Failed to discover tests from assembly D:\a\1\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\1\s\API\MyProject.ApiTests\bin\Release\netcoreapp3.1\de\Microsoft.TestPlatform.CommunicationUtilities.resources.dll] Failed to discover tests from assembly D:\a\1\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.
等等。
我尝试升级/降级 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 一起工作。谢谢。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。