TeamCity dotCover report path for Sonar

Dipesh picture Dipesh · Nov 1, 2012 · Viewed 7k times · Source

I'm trying to integrate the sonar analysis into by TeamCity build process. I have a NUnit build step which runs my unit tests and then runs dotCover for the coverage.

My next step is the sonar-runner. The configuration that currently exists is; gallio.mode=dotCover, sonar.gallio.mode=reuseReport but I also need sonar.gallio.reports.path.

Does anybody know the path to the dotCover report generated in the the previous step?

Answer

Oleksandr picture Oleksandr · Nov 26, 2014

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:

  1. Create a PowerShell Build step in Team City after the step with test and coverage
    • you may use Command line if you prefer
  2. Get the full dotCover snapshot name in temp folder
  3. Run dotCover to produce a HTML report from a snapshot
    • Note - Sonar (c# plugin v 2.3) supports only dotCover HTML reports
  4. 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