Publish Code Coverage Report in Azure DevOps Services pipeline execution summary.

Posted by

This post has been republished via RSS; it originally appeared at: New blog articles in Microsoft Community Hub.

This blog content is compiled by @Ahetejaz from Azure DevOps CSS support team. He helped a customer in implementing Code Coverage report as part of Pipeline execution summary page in Azure DevOps Service. 


Below screenshot shows the code coverage report published in pipeline summary page:





Steps to generate code coverage:

- Create .NET Core application using Visual Studio.

- From NuGet package download ‘coverlet.msbuild’.

Coverage tool can create coverage file required by either Jacoco or Cobertura.

Jacoco or Cobertura can populate the data to code coverage tab in Azure Pipeline run (refer above screenshot).


‘coverlet.msbuild’ is one such tool which can create such coverage to be used by the Cobertura and Jacoco.


- Pipeline uses below tasks to generate code coverage report.


  displayNameAgent job 1
  - checkoutself
  - taskUseDotNet@2
    displayNameNet Core sdk 2
  - taskDotNetCoreCLI@2
  - taskDotNetCoreCLI@2
      projects'**/*.csproj '
      arguments/p:CollectCoverage=true /p:CoverletOutputFormat=cobertura /p:CoverletOutput=$(Build.SourcesDirectory)/TestResults/Coverage/
  - taskreportgenerator@4
  - taskPublishCodeCoverageResults@1
    displayNamePublish code coverage

Points to Remember:

1.     The feature to have code coverage as part of DevOps UI is under development. Reference link - There is no fixed timeline as to when the feature would be available.

2.     If we use .NET Core projects, then we could use .NET Core task which would give code coverage in the build logs. *Not in DevOps UI*.




3.  Publish code coverage result task supports coverage result formats such as Cobertura and JaCoCo. To use the task we would need to use a code coverage tool as part of the project solution. We may add a Nuget package to get the tool added to generate code coverage file required by either Cobertura or JaCoCo. Cobertura or JaCoCo could then populate the data to the code coverage tab. Coverlet.msbuild is one such tool which can create such coverage to be used by the Cobertura and JaCoCo.

4.     Before using publish code coverage result task we might need to understand that this task comes with certain limitation as mentioned in the article -

5.     For .NET Framework (4.7.2) project which does not use SDK style will not publish code coverage result in DevOps UI.

6.     For .NET Core project, we will be able to publish code coverage result using 3rd party component mentioned in point 3. Also, we used an extra task ‘ReportGenerator’ which is *NOT* owned by Microsoft to publish the results. Support for this task will not be provided by Microsoft.


Two link that might be handy for reference:




Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.