TeamCity dotCover report path for Sonar
It seems TeamCity 2017 no longer creates coverage_dotcover*.data files. Instead it creates *.dcvr files.
There are potentially multiple files which need to be merged before you can create the report. As a result the powershell need updating.
So using the steps provided by Oleksandr, just update the script to be:
$snapshotfiles = Get-ChildItem "%system.teamcity.build.tempDir%" `
-recurse -Filter *.dcvr `
| select -ExpandProperty Name
$snapshots = $snapshotfiles -join ";"
%teamcity.dotCover.home%\dotCover.exe merge /Source=$snapshots
/Output=dotcovermerge.dcvr
%teamcity.dotCover.home%\dotCover.exe report `
/ReportType=HTML /Source=dotcovermerge.dcvr `
/Output="%sonar.coverageReport%"
Then the property %sonar.coverageReport% can be passed to the sonarqube scanner. Btw, you need to create a parameter in TC for %sonar.coverageReport% e.g. "sonarcoverage.html"
Spent some amount of time on the same issue, but with newer Sonar c# plugin (v.2.3) - Gallio support has been dropped, but the report is still required.
To answer the question directly, TeamCity puts dotcover snapshot file into a temp folder with a name like coverage_dotcover27574681205420364801.data
(where digits are random). So
The procedure is:
- Create a PowerShell Build step in Team City after the step with test and coverage
- you may use Command line if you prefer
- Get the full dotCover snapshot name in temp folder
- Run dotCover to produce a HTML report from a snapshot
- Note - Sonar (c# plugin v 2.3) supports only dotCover HTML reports
- Pass the produced HTML report to sonar
PowerShell script:
$snapshot = Get-ChildItem "%system.teamcity.build.tempDir%" `
-Filter coverage_dotcover*.data `
| select -ExpandProperty FullName -First 1
%teamcity.dotCover.home%\dotCover.exe report `
/ReportType=HTML /Source="$snapshot" `
/Output="%sonar.coverageReport%"
Now you can specify your report in sonnar runner as sonar.cs.dotcover.reportsPaths='%sonar.coverageReport%'
Where %sonar.coverageReport% is a defined property in a TeamCity