简体   繁体   中英

The SonarQube MSBuild integration failed - SonarQube 7 with Scanner 4.0.2.892 and VS2017

I'm using SonarQube 7.0 and SonarQube Scanner for MSBuild 4.0.2.892 and attempting to follow these instructions to scan my .NET application on Windows (ASP.NET Core). The three commands below are part of the instructions:

C:\SonarQube\Scanner\SonarQube.Scanner.MSBuild.exe begin /k:"org.sonarqube:sonarqube-scanner-msbuild" /n:"TradingPlatform" /v:"1.0"
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe" /t:Rebuild
C:\SonarQube\Scanner\SonarQube.Scanner.MSBuild.exe end

However, while pre-processing succeeds on the fist command, and the build completes on the second command, the third command always fails as shown below:

====

SonarQube Scanner for MSBuild 4.0.2 Default properties file was found at C:\\SonarQube\\Scanner\\SonarQube.Analysis.xml

Loading analysis properties from C:\\SonarQube\\Scanner\\SonarQube.Analysis.xml

Post-processing started.

The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects.

Possible causes:

  1. The project has not been built - the project must be built in between the begin and end steps
  2. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0 upwards are supported
  3. The begin, build or end steps have not all been launched from the same folder

Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.

Exit Code 1.

====

Does anyone have any idea why it's failing? Cause 1 can't be the case as I'm building the project in step 2. Cause 2 seems very unlikely (but not impossible) as I'm using MSBuild 15. Cause 3 also can't be the case as I'm running all three commands from the same location

Other possible reasons are:

  • your build server is executing the builds using Local System account. Try changing the build user to a normal domain or local user.
  • you are building a .NET Core project that has no ProjectGuid property (the default) and that is not part of a solution. To resolve this you need to do one of these:
    • Add <ProjectGuid>XXXXX</ProjectGuid> element in the first PropertyGroup in your csproj, where XXXXX is a newly generated Guid.
    • Add your project to a Visual Studio solution and build the sln file instead of the csproj

If this does not help, add /d:sonar.verbose=true on the begin command of the scanner and save all logs into a file. Zip the logs and the .sonarqube folder from your build workspace and upload them here: https://www.dropbox.com/request/CszJAO1ZNXFVl1gwo5hA

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM