1
votes

I have a .net core whith CI in Azure devops.

After successfully running my unit tests, I would like to generate and display code coverage using ReportGenerator, based on this article:

https://www.meziantou.net/computing-code-coverage-for-a-dotnet-core-project-with-azure-devops-and-coverlet.htm

Part of the YAML:

- script: |
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator -reports:$(Build.SourcesDirectory)/**Tests/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/CodeCoverage -reporttypes:HtmlInline_AzurePipelines;Cobertura
 displayName: Create Code coverage report

This gives me the folling error:

...line 2: Cobertura: command not found

By removing the Cobertura from reporttypes, there are no errors, but then there are no report to be shown.

How can I install or enable Cobertura?

2

2 Answers

3
votes

By removing HtmlInline_AzurePipelines from reporttypes, it worked

1
votes

This way you are skipping a parameter option. Accordingly to the documentation, you can try to wrap that option with " like in the following:

    - script: |
dotnet tool install -g dotnet-reportgenerator-globaltool
reportgenerator -reports:$(Build.SourcesDirectory)/**Tests/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/CodeCoverage "-reporttypes:HtmlInline_AzurePipelines;Cobertura"
 displayName: Create Code coverage report

This should probably work as well without skipping it.