1
votes

We have a solution with 5 projects inside.

After running the MSBuild runner, our sonar only contains the analysis of one project instead of the complete solution.

Execution:

cd K:\sonarRoot

D:\BuildTools\MSBSonarQubeRunner-1.0.2\MSBuild.SonarQube.Runner.exe begin /k:"solutionKey" /n:"solutionName" /v:"solutionVersion" /d:sonar.resharper.cs.reportPath="K:\<pathToXml>\resharper.xml" /d:sonar.resharper.solutionFile="K:\<pathToSolution>\solution.sln"

C:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe K:\<pathToSolution>\solution.sln /t:rebuild /p:Configuration=Release /p:TargetFrameworkVersion="v4.5.2" /verbosity:n /flp1:logfile=D:\ModuleBuild\Workspace\builderrors.txt;errorsonly;append=true    

D:\BuildTools\ReSharperCommandLineTools\inspectcode.exe "K:\<pathToSolution>\solution.sln" /o="K:\<pathToXml>\resharper.xml"    

D:\BuildTools\MSBSonarQubeRunner-1.0.2\MSBuild.SonarQube.Runner.exe end > D:\ModuleBuild\Workspace\sonar.out 2> D:\ModuleBuild\Workspace\sonar.err

This all runs fine, except that just one solution shows up in Sonar... For every file in the solution that is not in the project, we get a line in the runner output like this:

12:14:43.513 INFO - Skipping the ReSharper issue at line 262 whose file "{pathToSource}\ChangeListHelper.cs" is not in SonarQube.

Somehow the sonar-project.properties that gets generated from the MSBuild runner contains a sonar.projectname of the project and not the solution. And the sonar.projectBasedir is also set to the project.

How are we supposed to fix it, so the complete solution gets analyzed?

1
For each project in your solution, the runner will generate modules in your properties file. The base dir should point to the root location of your solution file. Is this the case for you? Not exactly sure, what kind of trouble you are running in. But, the output you are getting from R# is because you are analyzing a multi project solution. The analyser just parses the entire resharper.xml for each project analysis and ignores issues that are not related to your project. The sonar resharper plugin doesn't apply a filter per project. See: jira.sonarsource.com/browse/SONARRSHPR-21. - Rik van den Berg
The problem is that the base dir does NOT point to the root location. We want to analyze all projects in the whole solution and display the result correctly in sonar (=> so that we can see all the analysis off al projects in sonar when we click on the solution) - ThejustOli
This seems stange indeed - how many folders do you have in .sonarqube\out after the analysis? There should be one per project, and a .sonar one if you've already executed the end step. In the generated sonar-project.propeties, look for the sonar.modules= line at the end of the file, what is its value? - Dinesh Bolkensteyn
I have a .sonar folder and one folder that is named like this: <application name>_AnyCPU_Release_<number> If there should be one per project then there are definitely some missing (6 projects in that solution). The value of the sonar.modules is a GUID... - ThejustOli
The begin, MSBuild and end commands need to be run from the same directory - see this answer. It doesn't matter where you run ReSharper from as the path to the report file is specified explicitly. - duncanp

1 Answers

0
votes

Is there a possibility that your <pathToSolution>\Solution.sln include *\test\* in there? default configuration ignores projects by that regex.

If, let's say, all but that one project were in ' K:\myWork\thisSolution\test\ProjectA and ProjectB and ProjectC and the final one was K:\myWork\thisSolution\app\ProjectD And ProjectD was the only one being analyzed, then that would be why.

See MSBuild SonarQube runner in command line for other SO discussion on this topic.