1

I'm trying out SonarQube using the new MSBuild SonarQube Runner v1.0.

The Pre-processing works fine

E:\sonarQube\MSBuild.SonarQube.Runner-1.0>MSBuild.SonarQube.Runner.exe begin /k:"MyKey" /n:"MyProject" /v:"1.0"
.......
Process returned exit code 0
Pre-processing succeeded.

Then MSBuild works

E:\sonarQube\WebApplication2013>msbuild
Microsoft (R) Build Engine version 4.0.30319.34209
[Microsoft .NET Framework, version 4.0.30319.34209]
Copyright (C) Microsoft Corporation. All rights reserved.
........

Done Building Project "E:\sonarQube\WebApplication2013\WebApplication2013.sln" (default targets).


Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:00.51

While end command following error gets generated

E:\sonarQube\MSBuild.SonarQube.Runner-1.0>MSBuild.SonarQube.Runner.exe end
.......
6:35:10 PM  Generating SonarQube project properties file to E:\sonarQube\MSBuild.SonarQube.Runner-1.0\.sonarqube\out\sonar-project.properties
6:35:10 PM  No ProjectInfo.xml files were found. Check that the analysis targets are referenced by the MSBuild projects being built.
6:35:10 PM  Writing processing summary to E:\sonarQube\MSBuild.SonarQube.Runner-1.0\.sonarqube\out\ProjectInfo.log
6:35:10 PM  Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
6:35:10 PM  Creating a summary markdown file...
Process returned exit code 1
Post-processing failed. Exit code: 1

Required your assistance

Pascal Berger
  • 4,262
  • 2
  • 30
  • 54
  • Are you running all of the commands from the same directory? When running from the command line, the MSBuild.SonarQube.Runner creates a temporary _.sonarqube_ folder under the current directory that contains config data that is used during the MSBuild phase. If you are executing the MSBuild command from a different directory then the integration targets won't be able to find the config data and won't produce any ProjectInfo.xml files. Similarly, the call to _MSBuild.SonarQube.Runner end_ also uses the _.sonarqube_ temp directory so it needs to be run from the same directory too. – duncanp Sep 11 '15 at 08:01
  • My directory structure is like the E:\sonarQube\MSBuild.SonarQube.Runner-1.0\MSBuild.SonarQube.Runner.exe which is run through windows command prompt. And my project is in E:\sonarQube\WebApplication2013\WebApplication2013.sln where msbuild runs through Visual Studio command prompt – user3215248 Sep 11 '15 at 09:06
  • I can see you ran the analysis using MSBuild 4.0. Make sure you place the path to MSBuild 12.0 into your PATH environment variable, so MSBuild.SonarQube.Runner will use the correct one. – anthonymonori Nov 18 '15 at 08:30

2 Answers2

2

As pointed out by duncanpMS's comment, you need to run all the 3 commands from the folder of the project you want to analyze.

Here is how:

  1. cd E:\sonarQube\WebApplication2013
  2. E:\sonarQube\MSBuild.SonarQube.Runner-1.0\MSBuild.SonarQube.Runner.exe begin /k:"MyKey" /n:"MyProject" /v:"1.0"
  3. msbuild /t:rebuild
  4. E:\sonarQube\MSBuild.SonarQube.Runner-1.0\MSBuild.SonarQube.Runner.exe end

You can add E:\sonarQube\MSBuild.SonarQube.Runner-1.0 to your %PATH% environment variable so that you can simply type MSBuild.SonarQube.Runner.exe instead of the full path from the command line when you analyze projects.

Dinesh Bolkensteyn
  • 2,971
  • 1
  • 17
  • 20
  • Thanks it helped me to work. Then it shown me database connection error. After updating the database connection string from sql server to my sql, It is showing me **Unable to read the SonarQube analysis settings file 'E:\sonarQube\MSBuild.SonarQube.Runner-1.0\SonarQube.Analysis.xml'. Please fix the content of this file.** What could be the problem here – user3215248 Sep 11 '15 at 12:30
  • I guess there simply is an issue with the XML formatting, perhaps you missed a closing tag, or added some special characters without escaping them. You can use Visual Studio to edit the XML or another IDE and validate that it is well-formed. – Dinesh Bolkensteyn Sep 11 '15 at 12:38
1

You need msbuild version 12 or version 14. If you have VS2013 , Msbuild version 12 comes with it. If you have VS2015, Msbuild version 14 comes with it.

If you don't have , download Microsoft Build Tools 2013 or 2015.

Run Msbuild -version to verify the version before running the 3 commands sequentially in the solution folder.

Ashraff Ali Wahab
  • 1,088
  • 9
  • 19