如何解决Atlassian管道MSB3026等上的dotnet测试错误
具有一个yaml文件构建脚本,并且除单元测试外一切正常,但单元测试在各种警告最终导致MSB3027和MSB3021错误后失败。
这是Atlassian中的管道。
看到过提及长PATH名称的问题,但如何在此处解决?之前有类似的管道设置和工作。
image: mcr.microsoft.com/dotnet/core/sdk:3.1
pipelines:
branches:
develop:
- step:
name: Build and Test
caches:
- dotnetcore
script:
- export ENV_NAME=develop
- export PROJECT_NAME=Myapi
- export ZIP_FILE=Myapi-dev.zip
- export TEST_PROJECT=Myapi.Tests
- dotnet build $PROJECT_NAME
- dotnet test $TEST_PROJECT --no-build --configuration Release
# this will publish our app output into a subfolder so that we can package it up
- dotnet publish $PROJECT_NAME --output $ENV_NAME/publish --configuration release
/usr/share/dotnet/sdk/3.1.402/Microsoft.Common.CurrentVersion.targets(4364,5):
warning MSB3026: Could not copy "/root/.nuget/packages/microsoft.testplatform.objectmodel/16.7.1/lib/netstandard2.0/pt-BR/Microsoft.TestPlatform.CoreUtilities.resources.dll"
to "bin/Release/netcoreapp3.1/pt-BR/Microsoft.TestPlatform.CoreUtilities.resources.dll". Beginning retry 1 in 1000ms.
Could not find a part of the path '/opt/atlassian/pipelines/agent/build/myapi/bin/Release/netcoreapp3.1/pt-BR/Microsoft.TestPlatform.CoreUtilities.resources.dll'.
解决方法
最后,这是第三方组件,并且Test项目所需的资源文件不在构建管道的预期位置。我通过将所需的文件复制到目标位置来解决该问题。
# Workaround for resource file case sensitivity issue
- ls -lR .
- cp -R ./Myapi/bin ./Myapi.Tests/bin
- cp -R ./Myapi/bin/Debug/netcoreapp3.1/pt-br ./Myapi.Tests/bin/Debug/netcoreapp3.1/pt-BR
- dotnet test $TEST_PROJECT
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。