azure-devops.net-6.0dotnet-test

Fixate version of Test Execution Command Line Tool


There is a bug in the Microsoft (R) Test Execution Command Line Tool Version 17.4.0 and we like to use 17.3.1.

We are doing dotnet test in our Azure Pipeline:

- task: UseDotNet@2
  displayName: 'Use .NET 6'
  inputs:
    packageType: 'sdk'
    version: '6.0.x'

# build tasks etc.

- task: DotNetCoreCLI@2
  displayName: Run Unit Tests
  inputs:
    command: 'test'
    projects: '$(testProjects)'
    # ... more config

But for some reason, this gives us sometimes 17.4.0 and sometimes 17.3.1 - even with the same code (rebuild of the same commit). This is probably because our build agents are shared with other teams.

Is there a way to force the version 17.3.1 of Test Execution Command Line Tool?

Background info

For the issue, see microsoft/vstest - issue #4140 - 17.4.0 Breaks pipeline code coverage


Solution

  • For the issue about pipeline code coverage, the cause of the issue is that there are known issues with .Net7 and Test Tool version 17.4.0. For more detailed info, you can refer to this Github ticket: dotnet test does not forward MSBuild properties to msbuild in .NET 7 RC1

    Is there a way to force the version 17.3.1 of Test Execution Command Line Tool?

    Yes. You can force the version 17.3.1 via adding the dotnet test argument: -p:VSTestConsolePath=localpath.

    Here is an example:

    - task: DotNetCoreCLI@2
      displayName: Test
      inputs:
        command: test
        projects: '**/The.Tests.csproj'
        arguments: '-p:VSTestConsolePath="C:\Users\VssAdministrator\.nuget\packages\microsoft.testplatform.portable\17.3.1\tools\netcoreapp2.1\vstest.console.dll"  /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura  /p:CoverletOutput=./coverage.cobertura.xml"'
    

    Note: you need to install the package:Microsoft.TestPlatform.Portable:17.3.1 before running the dotnet test.

    On the other hand, confirmed by the Test Platform team that this issue related to Test Tool 17.4.0 will be resolved in December timeframe