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