2

I have setup SonarQube with the following: sonarqube-5.4, MSBuild.SonarQube.Runner-2.0, VS 2013 (target .NET Framework 4.5.1), SQL Server 2014 Express, Windows 7 Professional SP1 64-bit OS.

I am able to execute sonarqube runner for one .NET project (.csproj) successfully and generate the results. Now I would like to execute MSBuild.SonarQube.Runner-2.0 for a .NET solution (.sln) which has many .csproj entries.

The folder structure is as below:

RootFolder has a .sln file, and each project (.csproj) is created in a separate folder inside the root folder. Unit tests for each project are also created in a separate folder inside the root folder. For example:

RootFolder -> Project.sln
RootFolder -> ProjectABCFolder -> ProjectABC.csproj
RootFolder -> ProjectABCTestsFolder -> ProjectABCTests.csproj
RootFolder -> ProjectXYZFolder -> ProjectXYZ.csproj
RootFolder -> ProjectXYZTestsFolder -> ProjectXYZTests.csproj

Can you help me on the following ?

  1. How to execute the .sln file - what the required entries / settings to be made ?
  2. How to skip the unit test projects ?
  3. How to include the unit test projects ?
  4. How to execute the VS Code Analysis ?
alex
  • 6,818
  • 9
  • 52
  • 103
Bhanu
  • 831
  • 3
  • 13
  • 28

1 Answers1

2

Almost all of this is covered here exception for the unit test exclusion.

http://docs.sonarqube.org/display/SCAN/From+the+Command+Line

To run for the whole solution you should be able to just run the following from your RootFolder:

MSBuild.SonarQube.Runner.exe begin // Other args
msbuild /t:Rebuild Project.sln
MSBuild.SonarQube.Runner.exe end

As for your unit test questions. Most people choose not to include the test code in the project. This is done via the regex in the sonarqube UI: Administration->Scanner for MSBuild. Changing this regex to something that doesn't match for your test projects will cause them to be included.

Mike Barry
  • 953
  • 5
  • 15
  • Thanks for the response, I did the same. I have added the regex "/.Tests/" to exclude the test projects (ProjectABC.Tests.csproj, ProjectXYZ.Tests.csproj etc.) But still the test projects are also being evaluated and then the analysis fails. How to exclude test projects from execution ? – Bhanu Apr 26 '16 at 11:27
  • The default regex should be excluding tests with the name you specified. Change it back to the default and post a link to the runner output if there is nothing proprietary in it. – Mike Barry Apr 26 '16 at 12:05