0
votes

We've recently updated the C# plugin for SonarQube after which we had to use the MSBuild Runner v1. Since the update Code Coverage is no longer imported into sonrqube.

TFS2013 Build generates the codecoverage report which is picked up by the MSBuild runner and is converted (as seen below in the diagnostic view of the build).

"Run optional script after Test Runner"

11:09:43 AM Attempting to locate the CodeCoverage.exe tool...
11:09:43 AM Code coverage command line tool: C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
11:09:43 AM Fetching code coverage report information from TFS...
11:09:43 AM Connecting to TFS...
11:09:43 AM Fetching build information...
11:09:43 AM Fetch code coverage report info...
11:09:43 AM Commencing retry-able operation. Max wait (milliseconds): 20000, pause between tries (milliseconds): 2000
11:09:43 AM Operation succeeded. Elapsed time (ms): 18
11:09:43 AM Coverage Id: 2623, Platform Any CPU, Flavor Any CPU
11:09:43 AM ...done.
11:09:43 AM The directory already exists: ***\.sonarqube\out
11:09:43 AM Connected to http://tfs***/tfs/***
11:09:43 AM Downloading coverage file from http://tfs***/tfs/**** ***\.sonarqube\out\VSCodeCoverageReport.coverage
11:09:50 AM Executing file C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Dynamic Code Coverage Tools\CodeCoverage.exe
Args: analyze /output:"***\.sonarqube\out\VSCodeCoverageReport.coveragexml" "***\.sonarqube\out\VSCodeCoverageReport.coverage"
Working directory: ***\.sonarqube\out
Timeout (ms):30000
Process id: 5420
11:09:50 AM Process returned exit code 0
11:09:50 AM Updating project info files with code coverage information...

We are using VS 2013, TFS 2013, Sonarqube 5.1.2, MSBuild runner 1

CodeCoverage was working before upgrading to C# plugin 4.1 and using the MSBuild Runner. Any help getting the code coverage to work would be great.

2
We've reverted the plugin and runner to sonarqube c# 4 plugin and are using the sonar-runner which picks up the codecoverage correctly due to no feedback and no simple fixes in the sourcecode on github that we could seefluf

2 Answers

0
votes

Apologies for not replying sooner, I think we aren't looking at the "sonarqube5.1" tag specifically, but at the "sonarqube" tag.

There are a few things we could check, so first:

You say you upgraded to MSBuild Runner v1.0. What did you upgrade from? Were you using MSBuild Runner v0.9 or the Visual Studio Bootstrapper? For the 0.9 -> 1.0 we have documented the upgrade process - did you follow these steps?

0
votes

With msbuild sonarqube runner 1.0.1 I had trouble getting opencover reports imported where it used to work before. It turns out I had to make sure the sonar.cs.opencover.reportsPaths argument uses absolute paths to the reports, because the working directory is different from when I ran sonar-runner.bat directly before.