Convert .coverage
(binary format) files to .coveragexml
(xml format) files to support SonarCloud Code Coverage when using VSTest@2.
Install locally:
dotnet tool install --global dotnet-coverageconverter
or
Install the tool in your yml pipeline:
- task: DotNetCoreCLI@2
displayName: "Install tool: dotnet-coverageconverter"
inputs:
command: 'custom'
custom: 'tool'
arguments: 'update --global dotnet-coverageconverter'
- Step 1: Define a VSTest@2 task with
codeCoverageEnabled: true
- Step 2: Define a CmdLine@2 task with the
dotnet-coverageconverter
-tool and provide the CoverageFilesFolder where the.coverage
files are placed by vstest.console.exe
- task: VSTest@2
displayName: 'VsTest'
inputs:
testSelector: 'testAssemblies'
vsTestVersion: 16.0
diagnosticsEnabled: true
codeCoverageEnabled: true
testAssemblyVer2: |
**\*tests.dll
!**\*UITests.dll
!**\*TestAdapter.dll
!**\obj\**
- task: CmdLine@2
displayName: 'Convert .coverage to .coveragexml'
inputs:
script: 'dotnet-coverageconverter --CoverageFilesFolder "$(Agent.TempDirectory)\TestResults"'
-f, --CoverageFilesFolder Required. The folder where the .coverage files are defined.
-d, --DotCoverageExtension (Default: .coverage) The extension from the coverage files.
-a, --AllDirectories (Default: true) Includes also sub-folders in the search operation.
-p, --ProcessAllFiles (Default: false) Process all .coverage files, if not set, then only folders which are a guid (that's the one VSTest creates) will be processed.
-o, --Overwrite (Default: true) Overwrite the existing .coveragexml files.
-r, --RemoveOriginalCoverageFiles Remove the original .coverage files.
--help Display this help screen.
--version Display version information.
This project is inspired by Visual-Studio-Coverage-Tools.