Microsoft’s newer tools (dotnet-coverage, Microsoft.CodeCoverage.Console) don’t support direct .coverage -> XML/ Cobertura conversion. The old CodeCoverage.exe is deprecated, so automation requires third-party tools or an intermediate step.
Options:
1. Use ReportGenerator (recommended)
· ReportGenerator supports .coverage files directly and can export to Cobertura, XML and HTML.
· Install via NuGet or as a .NET global tools:
Dotnet tool install –g dotnet-reportgenerator-globaltool
· Example pipeline step:
Reportgenerator -reports:coverage.coverage -targetdir:coverage-report -reporttypes:Cobertura
· This will generate coverture.xml suitable for GitHub Actions, Azure DevOps, Jenkins etc.
2. Covert .coverage to .coveragexml with visual studio test platform( vstest.console.exe)
· Run tests with coverage enabled and export XML:
Vstest.console.exe MyTests.dll /EnableCodeCoverage /Logger:trx
· Then use ReportGenerator to produce Cobertura/HTML reports from the .coveragexml.
3. Switch to coverlet for .NET (if possible)
· For c# /.NET core projects, coverlet.collector integrates directly with dotnet test and outputs Covertura/LCOV/JSON without conversion:
Dotnet test /p:CollectCoverage=true /p:CoverletOutputForms- cobertura.
Reference links:
· GitHub - coverlet-coverage/coverlet: Cross platform code coverage for .NET