dotnet test errors on Atlassian pipeline MSB3026 and more

404 Views Asked by At

Have a yaml file build script and all works fine except for the unit test which fails after various warnings eventually raising MSB3027 and MSB3021 errors.

This is in a pipeline in Atlassian.

Seen issues mentioning long PATH names but how to resolve here? Have similar pipelines setup and working before.

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'.
1

There are 1 best solutions below

0
On

In the end this was a third party component and the resource file the Test project needed was not in the expected location for the build pipeline. I worked around the issue by copying the files it needed into the target location.

# 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