SonarCloud is not reporting code coverage

I’m currently using TeamCity to build a C# MVC Web App and SonarCloud to display the code metrics including code coverage.

Currently the code coverage is displaying 0% however I can verify in the build log that SonarCloud is accepting and processing the dotCover code coverage report:

Any help is appreciated.

After leaving it overnight the coverage is now suddenly eing displayed:

Hi,

Can you please help me out what parameters you have used to configure code coverage using dotcover reports… I am also facing similar issue and stuck with it.

Any help is highly appreciated.

Thanks,
Ram

1 Like

I used the following parameter for dotcover when running SonarScanner.MSBuild.exe begin
/d:sonar.cs.dotcover.reportsPaths=%teamcity.build.checkoutDir%\coverage.html

The dotcover report will be specified to be created at the location of %teamcity.build.checkoutDir%

I then use a Powershell script I got from StackOverflow to pick up the dotcover raw data with a generated suffix and move it to a specified location with a fixed name.

$snapshot = Get-ChildItem “%system.teamcity.build.tempDir%” -Filter coverage_dotcover*.data
| select -ExpandProperty FullName -First 1
copy $snapshot %teamcity.build.checkoutDir%\coverage_dotcover.data

I then use a final CommandLine (cmd) step to create a HTML report

dotCover.exe report /ReportType=HTML /Source=%teamcity.build.checkoutDir%\coverage_dotcover.data /Output=%teamcity.build.checkoutDir%\coverage.html

Everything else is as normal. It’s a bit hacky but it seems to be working. Hope this helps others.