1

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?

Pascal Berger
  • 4,262
  • 2
  • 30
  • 54
ThejustOli
  • 137
  • 1
  • 2
  • 7
  • 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: https://jira.sonarsource.com/browse/SONARRSHPR-21. – Rik van den Berg Dec 20 '15 at 13:54
  • 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 Dec 21 '15 at 07:32
  • 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 Dec 21 '15 at 08:04
  • I have a .sonar folder and one folder that is named like this: _AnyCPU_Release_ 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 Dec 21 '15 at 09:03
  • The *begin*, *MSBuild* and *end* commands need to be run from the same directory - see [this answer](http://stackoverflow.com/questions/33555541/is-it-possible-to-run-the-msbuild-sonarqube-runner-on-a-csproj-file-as-opposed-t). It doesn't matter where you run ReSharper from as the path to the report file is specified explicitly. – duncanp Jan 11 '16 at 11:33
  • As you can see above, I change the current directory to K:\sonarRoot. All commands get executed from that current directory. Analyzings works fine except the part that only one project of the complete solution gets analyzed. – ThejustOli Jan 14 '16 at 13:50
  • My mistake. As Dinesh says above, there should be one folder under *.sonarqube\out* per project that is built. This folder is created by the SQ integration targets during the build stage. The most likely reasons for a folder not being created are the following: (1) the project is not being built (e.g. it isn't included in the configuration being built), (2) the project is not being built successfully, and (3) the targets files are not being imported into the project (not likely in this case since one of the projects is being built). – duncanp Jan 16 '16 at 13:56

1 Answers1

0

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.

Community
  • 1
  • 1
Dan M.
  • 29
  • 1
  • 6