K V
K V

Reputation: 578

TeamCity with SonarQube for Code Analysis build fails

Very common problem for many users, that SonarQube Code Analysis fails with an error:

[10:06:05]No ProjectInfo.xml files were found. Possible causes: 
[10:06:05]1. The project has not been built - the end step was called right 
after the begin step, without a build step in between 
[10:06:05]2. An unsupported version of MSBuild has been used to build the 
project. Currently MSBuild 12.0 upwards are supported
[10:06:05]3. The build step has been launched from a different working folder
[10:06:05]Post-processing failed. Exit code: 1
[10:06:05]Process exited with code 1

A lot of references say that fix is to use full path for MSBuild.exe, but yes, I use full path, but also I use MSBuild 15.0 version with newest C# version, older MSBuild just fails for new C# features in code.

However I can't get rid of this error and I have no idea what can be done about it, so maybe any of you guys have already met this problem and could help me?

EDITED

I am pretty sure that none of these steps should be the reason for the fail, the second one only the closest one, because my build steps are

Team City build steps look like the following.

Step XX:

cd %projectDirectory%
"C:\sonarqube-5.3\bin\MSBuild.SonarQube.Runner\MSBuild.SonarQube.Runner.exe" begin   ... params
"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe" "MyProject.sln" /t:Clean;Rebuild

Step XY:

...

Step XZ: (the last)

cd %projectDirectory%
"C:\sonarqube-5.3\bin\MSBuild.SonarQube.Runner\MSBuild.SonarQube.Runner.exe" end

For me it looks very simple and easy to understand, but still I got that error and I have no idea why, the error is thrown in the last step (XZ).

Upvotes: 0

Views: 775

Answers (1)

duncanp
duncanp

Reputation: 1590

You need to upgrade to a newer version of the Scanner for MSBuild. I'd suggest upgrading to the newest available version (v4.2 at the time of writing).

The scanner copies a targets file under the following location for each supported version of MBuild: %localappdata%\Microsoft\MSBuild[MSBuild version]\Microsoft.Common.targets\ImportBefore.

From the look of the log output you are using an version of the Scanner for MSBuild that pre-dates the release of MSBuild 15, so the file won't be copied to the MSBuild15-specific location. This will lead to the "no ProjectInfo.xml files were found" state.

It would be better if the warning message in the scanner log explicitly listed the range of MSBuild versions that were supported e.g. "This version of the Scanner supports MSBuild v12.0 to v14.0". I've created issue #502 to track this.

Upvotes: 2

Related Questions