How can I automatically convert Visual Studio .coverage files to XML or Cobertura format for use in CI pipelines?

Fatma-3378 0 Reputation points
2025-09-22T12:06:49.26+00:00

Hi,

I’m working on C++ projects with Visual Studio Enterprise and I can generate .coverage files for code coverage. However, I need to automatically convert these .coverage files to XML (preferably Cobertura) or HTML formats in my CI/CD pipeline, so that I can publish and visualize coverage results.

The CodeCoverage.exe tool is deprecated and doesn’t work reliably anymore, and the new tools like Microsoft.CodeCoverage.Console.exe or dotnet-coverage don’t support converting .coverage files to XML or Cobertura. I know I can export XML manually from the Visual Studio GUI, but that’s not suitable for automation.

Is there any supported Microsoft tool or recommended way to do this conversion automatically in a pipeline? Or is there any other way to integrate code coverage into a CI/CD pipeline for Github action?

Developer technologies | C++
Developer technologies | C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
{count} votes

1 answer

Sort by: Most helpful
  1. Adiba Khan 895 Reputation points Microsoft External Staff
    2025-09-23T09:09:42.9833333+00:00

    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 - danielpalme/ReportGenerator: ReportGenerator converts coverage reports generated by coverlet, OpenCover, dotCover, Visual Studio, NCover, Cobertura, JaCoCo, Clover, gcov or lcov into human readable reports in various formats.

    ·         GitHub - coverlet-coverage/coverlet: Cross platform code coverage for .NET


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.