0

I have AzureDevops pipeline to build and test my .net core Azure Functions solutions. Locally tests are working fine but they do fail on build Agent(I tried different agents)

Here is error log:

##[error]Error: The process 'C:\Program Files\dotnet\dotnet.exe' failed with exit code 1
##[error]Dotnet command failed with non-zero exit code on the following projects : C:\BuildAgent\_work\20\s\UnitTestProject\UnitTestProject.csproj
##[section]Finishing: Test

Error: enter image description here

Here is my yaml file:

trigger:
- dev

pool: 'SelfHosted'

variables:
  workingDirectory: '$(System.DefaultWorkingDirectory)/'

steps:
- task: DotNetCoreCLI@2
  displayName: Restore
  inputs:
    command: 'restore'
    projects: '**/*.csproj'
    feedsToUse: 'select'

- task: DotNetCoreCLI@2
  displayName: Build
  inputs:
    command: 'build'
    projects: '**/*.csproj'
    arguments: '--output $(System.DefaultWorkingDirectory)/publish_output --configuration Release'

- task: DotNetCoreCLI@2
  displayName: Test
  inputs:
    command: 'test'
    projects: '**/*.csproj'
    publishTestResults: false

Please suggest, thanks in advance!

Sergiy Kostenko
  • 273
  • 1
  • 2
  • 11

2 Answers2

1

When investigating above cs0579 duplicate AssemblyInfo error. It is probably because the test process provides assembly information separately and another AssemblyInfo.cs file get generated, which caused the duplication.

You can try below to make sure these assembly information is declared only once in your project.

1, Removing the AssemblyInfo.cs file from your project to prevent the duplication conflict.

2, you can try adding below lines to your .csproj files

<PropertyGroup>
  <GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

Please check this similar thread for more possible fixes

Levi Lu-MSFT
  • 27,483
  • 2
  • 31
  • 43
0

I faced similar issue with my automation code's Build pipeline with CI. I was using ".Net Core" task for test execution.

Solution:

  1. I switched my "test" execution task from .Net Core to "Visual Studio test".
  2. In VSTest task under "Test files" i specified exact project name which contains Test Cases. Instead of main solution.dll. As shown in image.

enter image description here

KR Akhil
  • 877
  • 3
  • 15
  • 32