Error on .Net framework C# projects: The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects

  • versions used : “sonarqube-developer-7.2.1”
  • error observed: “The SonarQube MSBuild integration failed: SonarQube was unable to collect the required information about your projects.”
  • More Description:
    I am using SonarScanner for MSBuild for .NET Framework (C# project).

For your information, please find below the System and software information of the machine where the SonarQube installed.


os.arch x86
os.name Windows 10
os.version 10.0
Version 7.2.1.14109
Version: sonarqube-developer-7.2.1
SonarScanner for MSBuild 4.6.1
Microsoft ® Build Engine version 14.0.23107.0
.Net version v4.5
Visual Studio 2013


  • steps to reproduce:
  1. I have installed SonarQube and all supporting software like Scanner for MSBuild and Microsoft Build Tolls as per the instruction and guide line mentioned in your portal.
  2. I can start the SonarQube service using command prompt
  3. I can Log in to http://localhost:9000 with System Administrator credentials (admin/admin)
  4. I can create project
  5. When I, Analyzing with SonarQube Scanner for MSBuild using the following commands:
    a) SonarScanner.MSBuild.exe begin /k:“MyProj02ForCodeAnalysis” [Successful]
    b) MSBuild.exe D:\Projects\MyProj02ForCodeAnalysis\Project2.sln /t:Rebuild [Successful]
    c) SonarScanner.MSBuild.exe end [Failed]
  6. In the above last command, the following error coming
    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*
    1. An unsupported version of MSBuild has been used to build the project. Currently MSBuild 14.0 and 15.0 are supported*
    1. The begin, build and end steps have not all been launched from the same folder*
    1. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)*
      Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
      20:50:09.446 Post-processing failed. Exit code: 1

The analyze tool is running upto 2nd command successfully. In the last command, error is coming. I have followed all the steps and instructions given in your portal. I am not getting any stats or report under http://localhost:9000. I can only see some analytics result from the above 2nd command and it is in command line. But not getting any proper report.

Hi @ajayindigo

Welcome to our community!

Would it be possible to run the scanner in verbose mode (/d:sonar.verbose=true) and post here the logs?

Thanks,
Costin

D:\Projects\Emdt_SQ>SonarScanner.MSBuild.exe begin /k:“10SecReOpen” /d:sonar.host.url=“http://localhost:9000 -> I will replace this URL in next lines with localhost only, because your community not allowed me to use more than 3 URL in a single post.” /d:sonar.verbose=true /d:sonar.login=“59db01dd8be2b6c54fd466025beaa29271264751”
SonarScanner for MSBuild 4.6.1
Using the .NET Framework version of the Scanner for MSBuild
Default properties file was found at C:\sonarqube\bin\scanner\SonarQube.Analysis.xml
Loading analysis properties from C:\sonarqube\bin\scanner\SonarQube.Analysis.xml
sonar.verbose=true was specified - setting the log verbosity to ‘Debug’
Pre-processing started.
Preparing working directories…
Using environment variables to determine the download directory…
18:14:37.257 18:14:37.251 Loading analysis properties from C:\sonarqube\bin\scanner\SonarQube.Analysis.xml
18:14:37.259 18:14:37.257 sonar.verbose=true was specified - setting the log verbosity to ‘Debug’
18:14:37.262 Updating build integration targets…
18:14:37.267 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\ajamohan\AppData\Local\Microsoft\MSBuild\4.0\Microsoft.Common.targets\ImportBefore
18:14:37.269 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\ajamohan\AppData\Local\Microsoft\MSBuild\10.0\Microsoft.Common.targets\ImportBefore
18:14:37.27 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\ajamohan\AppData\Local\Microsoft\MSBuild\11.0\Microsoft.Common.targets\ImportBefore
18:14:37.271 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\ajamohan\AppData\Local\Microsoft\MSBuild\12.0\Microsoft.Common.targets\ImportBefore
18:14:37.273 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\ajamohan\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.targets\ImportBefore
18:14:37.274 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\ajamohan\AppData\Local\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportBefore
18:14:37.275 Installed SonarQube.Integration.ImportBefore.targets to C:\Users\ajamohan\AppData\Local\Microsoft\MSBuild\Current\Microsoft.Common.targets\ImportBefore
18:14:37.277 Installed SonarQube.Integration.targets to D:\Projects\Emdt_SQ.sonarqube\bin\targets
18:14:37.278 Creating config and output folders…
18:14:37.279 Creating directory: D:\Projects\Emdt_SQ.sonarqube\conf
18:14:37.279 Creating directory: D:\Projects\Emdt_SQ.sonarqube\out
18:14:37.285 Fetching analysis configuration settings…
18:14:37.289 Downloading from localhost:9000/api/server/version…
18:14:37.31 Fetching properties for project ‘10SecReOpen’ from localhost:9000/api/settings/values?component=10SecReOpen…
18:14:37.312 Downloading from localhost:9000/api/settings/values?component=10SecReOpen…
18:14:37.392 Downloading from localhost:9000/api/languages/list…
18:14:37.401 Fetching quality profile for project ‘10SecReOpen’ from localhost:9000/api/qualityprofiles/search?projectKey=10SecReOpen…
18:14:37.403 Downloading from localhost:9000/api/qualityprofiles/search?projectKey=10SecReOpen…
18:14:37.482 Fetching active rules for quality profile ‘AWypqsh5ycxgu7n5YfTI’ from localhost:9000/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&activation=true&qprofile=AWypqsh5ycxgu7n5YfTI&p=1…
18:14:37.484 Downloading from localhost:9000/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&activation=true&qprofile=AWypqsh5ycxgu7n5YfTI&p=1…
18:14:37.675 Fetching rules not active in quality profile ‘AWypqsh5ycxgu7n5YfTI’ for language ‘cs’ from localhost:9000/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params&ps=500&activation=false&qprofile=AWypqsh5ycxgu7n5YfTI&p=1&languages=cs…
18:14:37.677 Downloading from localhost:9000/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params&ps=500&activation=false&qprofile=AWypqsh5ycxgu7n5YfTI&p=1&languages=cs…
18:14:37.8 Local analyzer cache: C:\Users\ajamohan\AppData\Local\Temp.sonarqube\resources
18:14:37.811 Writing Roslyn generated ruleset to D:\Projects\Emdt_SQ.sonarqube\conf\SonarQubeRoslyn-cs.ruleset…
18:14:37.823 Writing Roslyn generated ruleset to D:\Projects\Emdt_SQ.sonarqube\conf\SonarQubeRoslyn-cs-test.ruleset…
18:14:37.828 Provisioning analyzer assemblies for cs…
18:14:37.833 Installing required Roslyn analyzers…
18:14:37.834 Processing plugin: csharp version 7.3.0.5690
18:14:37.907 Cache hit: using plugin files from C:\Users\ajamohan\AppData\Local\Temp.sonarqube\resources\0
18:14:37.91 Processing plugin: vbnet version 7.1.0.5212
18:14:37.918 Cache hit: using plugin files from C:\Users\ajamohan\AppData\Local\Temp.sonarqube\resources\1
18:14:37.941 Writing Roslyn analyzer additional file to D:\Projects\Emdt_SQ.sonarqube\conf\cs\SonarLint.xml…
18:14:37.946 Fetching quality profile for project ‘10SecReOpen’ from localhost:9000/api/qualityprofiles/search?projectKey=10SecReOpen…
18:14:37.947 Downloading from localhost:9000/api/qualityprofiles/search?projectKey=10SecReOpen…
18:14:38.004 Fetching active rules for quality profile ‘AWypqsxvycxgu7n5YfmU’ from localhost:9000/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&activation=true&qprofile=AWypqsxvycxgu7n5YfmU&p=1…
18:14:38.007 Downloading from localhost:9000/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&activation=true&qprofile=AWypqsxvycxgu7n5YfmU&p=1…
18:14:38.064 Fetching rules not active in quality profile ‘AWypqsxvycxgu7n5YfmU’ for language ‘vbnet’ from localhost:9000/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params&ps=500&activation=false&qprofile=AWypqsxvycxgu7n5YfmU&p=1&languages=vbnet…
18:14:38.078 Downloading from localhost:9000/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params&ps=500&activation=false&qprofile=AWypqsxvycxgu7n5YfmU&p=1&languages=vbnet…
18:14:38.17 Local analyzer cache: C:\Users\ajamohan\AppData\Local\Temp.sonarqube\resources
18:14:38.173 Writing Roslyn generated ruleset to D:\Projects\Emdt_SQ.sonarqube\conf\SonarQubeRoslyn-vbnet.ruleset…
18:14:38.18 Writing Roslyn generated ruleset to D:\Projects\Emdt_SQ.sonarqube\conf\SonarQubeRoslyn-vbnet-test.ruleset…
18:14:38.183 Provisioning analyzer assemblies for vbnet…
18:14:38.191 Installing required Roslyn analyzers…
18:14:38.193 Processing plugin: csharp version 7.3.0.5690
18:14:38.2 Cache hit: using plugin files from C:\Users\ajamohan\AppData\Local\Temp.sonarqube\resources\0
18:14:38.209 Processing plugin: vbnet version 7.1.0.5212
18:14:38.212 Cache hit: using plugin files from C:\Users\ajamohan\AppData\Local\Temp.sonarqube\resources\1
18:14:38.222 Writing Roslyn analyzer additional file to D:\Projects\Emdt_SQ.sonarqube\conf\vbnet\SonarLint.xml…
18:14:38.246 Pre-processing succeeded.


D:\Projects\Emdt_SQ>SonarScanner.MSBuild.exe end /d:sonar.login=“59db01dd8be2b6c54fd466025beaa29271264751”
SonarScanner for MSBuild 4.6.1
Using the .NET Framework version of the Scanner for MSBuild
Post-processing started.
18:16:06.769 18:16:06.764 Uninstalling target: C:\Users\ajamohan\AppData\Local\Microsoft\MSBuild\4.0\Microsoft.Common.targets\ImportBefore\SonarQube.Integration.ImportBefore.targets
18:16:06.772 18:16:06.765 Uninstalling target: C:\Users\ajamohan\AppData\Local\Microsoft\MSBuild\10.0\Microsoft.Common.targets\ImportBefore\SonarQube.Integration.ImportBefore.targets
18:16:06.78 18:16:06.765 Uninstalling target: C:\Users\ajamohan\AppData\Local\Microsoft\MSBuild\11.0\Microsoft.Common.targets\ImportBefore\SonarQube.Integration.ImportBefore.targets
18:16:06.782 18:16:06.765 Uninstalling target: C:\Users\ajamohan\AppData\Local\Microsoft\MSBuild\12.0\Microsoft.Common.targets\ImportBefore\SonarQube.Integration.ImportBefore.targets
18:16:06.783 18:16:06.765 Uninstalling target: C:\Users\ajamohan\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.targets\ImportBefore\SonarQube.Integration.ImportBefore.targets
18:16:06.793 18:16:06.766 Uninstalling target: C:\Users\ajamohan\AppData\Local\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportBefore\SonarQube.Integration.ImportBefore.targets
18:16:06.794 18:16:06.766 Uninstalling target: C:\Users\ajamohan\AppData\Local\Microsoft\MSBuild\Current\Microsoft.Common.targets\ImportBefore\SonarQube.Integration.ImportBefore.targets
18:16:06.801 18:16:06.769 sonar.verbose=true was specified - setting the log verbosity to ‘Debug’
18:16:06.811 Loading the SonarQube analysis config from D:\Projects\Emdt_SQ.sonarqube\conf\SonarQubeAnalysisConfig.xml
18:16:06.814 Not running under TeamBuild
18:16:06.815 Analysis base directory: D:\Projects\Emdt_SQ.sonarqube
Build directory:
Bin directory: D:\Projects\Emdt_SQ.sonarqube\bin
Config directory: D:\Projects\Emdt_SQ.sonarqube\conf
Output directory: D:\Projects\Emdt_SQ.sonarqube\out
Config file: D:\Projects\Emdt_SQ.sonarqube\conf\SonarQubeAnalysisConfig.xml
Generating SonarQube project properties file to D:\Projects\Emdt_SQ.sonarqube\out\sonar-project.properties
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 and 15.0 are supported
  3. The begin, build and end steps have not all been launched from the same folder
  4. None of the analyzed projects have a valid ProjectGuid and you have not used a solution (.sln)
    Writing processing summary to D:\Projects\Emdt_SQ.sonarqube\out\ProjectInfo.log
    Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
    18:16:06.856 Post-processing failed. Exit code: 1

Hi @ajayindigo

Can you please confirm that the project has been build between the begin and end step and that all the steps have been launched from the same directory?

Also can you please attach the D:\Projects\Emdt_SQ.sonarqube\out\ProjectInfo.log and D:\Projects\Emdt_SQ.sonarqube\conf\SonarQubeAnalysisConfig.xml generated files?

Thank you,
Costin

Hi @ajayindigo

Since we support MSBuild starting with 14.0.25420 and that you are currently using 14.0.23107.0, it would be great if you could update the version and try again.

Thanks,
Costin

The D:\Projects\Emdt_SQ.sonarqube\out\ProjectInfo.log file content is as follows:

Product projects

Test projects

Invalid projects

{none}

Skipped projects

{none}

Excluded projects

{none}

The D:\Projects\Emdt_SQ.sonarqube\conf\SonarQubeAnalysisConfig.xml file content is as follows:

<?xml version="1.0" encoding="utf-8"?> D:\Projects\Emdt_SQ\.sonarqube\conf D:\Projects\Emdt_SQ\.sonarqube\out D:\Projects\Emdt_SQ\.sonarqube\bin D:\Projects\Emdt_SQ true http://localhost:9000 7.2.1.14109 10SecReOpen 7.3.0.5690 true true .c,.h .ts,.tsx SonarQube false oracle.jdbc.OracleDriver **/vendor/** false 60 .cc,.cpp,.cxx,.c++,.hh,.hpp,.hxx,.h++,.ipp SonarAnalyzer.CSharp false false false 100 target/jacoco.exec, target/jacoco-it.exec false true previous_version 30 SonarAnalyzer.VisualBasic true 30 52 https://secure.gravatar.com/avatar/{EMAIL_MD5}.jpg?s={SIZE}&d=identicon 600 amd, applescript, atomtest, browser, commonjs, couch, embertest, flow, greasemonkey, jasmine, jest, jquery, meteor, mocha, mongo, nashorn, node, phantomjs, prototypejs, protractor, qunit, rhino, serviceworker, shared-node-browser, shelljs, webextensions, worker, wsh, yui false **/node_modules/**,**/bower_components/** .vb .abap,.ab4,.flow,.asprog true 30 py .cs sql,pks,pkb SonarAnalyzer-7.1.0.5212.zip .java,.jav php,php3,php4,php5,phtml,inc .xml,.xsd,.xsl 260 $, jQuery 7.1.0.5212 .go 104 .swift false as xunit-reports/xunit-result-*.xml angular,goog,google,OpenLayers,d3,dojo,dojox,dijit,Backbone,moment,casper 24 **/node_modules/**,**/bower_components/** true false SonarAnalyzer.VisualBasic noreply@nowhere 7.1.0.5212 node 4 SonarAnalyzer.VisualBasic [SONARQUBE] c11 csharp true .m (branch|release)-.* SonarAnalyzer-7.3.0.5690.zip SonarAnalyzer.CSharp false coverage-reports/*coverage-*.xml SonarAnalyzer.CSharp false 0.05,0.1,0.2,0.5 false devcockpit,pdfreport,governance,ldap,authaad,authgithub,authbitbucket,googleanalytics 7.3.0.5690 .js,.jsx,.vue 20 vbnet false https://update.sonarsource.org/update-center.properties .tsql c++11 AWypqnBPycxgu7n5Yd-z 12/13/2019 4:25:40 PM http://localhost:9000 true cs D:\Projects\Emdt_SQ\.sonarqube\conf\SonarQubeRoslyn-cs.ruleset D:\Projects\Emdt_SQ\.sonarqube\conf\SonarQubeRoslyn-cs-test.ruleset C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\0\Google.Protobuf.dll C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\0\SonarAnalyzer.CSharp.dll C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\0\SonarAnalyzer.dll C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\1\SonarAnalyzer.VisualBasic.nuspec C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\1\[Content_Types].xml C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\1\analyzers\Google.Protobuf.dll C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\1\analyzers\SonarAnalyzer.dll C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\1\analyzers\SonarAnalyzer.VisualBasic.dll C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\1\package\services\metadata\core-properties\f124441cdae948bb922ac980ea59570c.psmdcp C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\1\tools\install.ps1 C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\1\tools\uninstall.ps1 C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\1\_rels\.rels D:\Projects\Emdt_SQ\.sonarqube\conf\cs\SonarLint.xml vbnet D:\Projects\Emdt_SQ\.sonarqube\conf\SonarQubeRoslyn-vbnet.ruleset D:\Projects\Emdt_SQ\.sonarqube\conf\SonarQubeRoslyn-vbnet-test.ruleset C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\0\Google.Protobuf.dll C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\0\SonarAnalyzer.CSharp.dll C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\0\SonarAnalyzer.dll C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\1\SonarAnalyzer.VisualBasic.nuspec C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\1\[Content_Types].xml C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\1\analyzers\Google.Protobuf.dll C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\1\analyzers\SonarAnalyzer.dll C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\1\analyzers\SonarAnalyzer.VisualBasic.dll C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\1\package\services\metadata\core-properties\f124441cdae948bb922ac980ea59570c.psmdcp C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\1\tools\install.ps1 C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\1\tools\uninstall.ps1 C:\Users\ajamohan\AppData\Local\Temp\.sonarqube\resources\1\_rels\.rels D:\Projects\Emdt_SQ\.sonarqube\conf\vbnet\SonarLint.xml

Hi Costin,
I have update the MSBuild version to 14.0.25420. But still getting the same error. Please note that I am doing source code review for .Net Framework “Website” not project/solution. Do SonarQube works for Website?

Hi @ajayindigo,

Can you check that in the following folder : C:\Users\ajamohan\AppData\Local\Microsoft\MSBuild you have proper “MSBuild version” subfolders, and inside each one of them, a target called “SonarQube.Integration.ImportBefore.targets” ?

Thank you.

in the folder C:\Users\ajamohan\AppData\Local\Microsoft\MSBuild and inside each “MSBuild version” subfolders, the following folder is present:
Microsoft.Common.targets\ImportBefore

Ok, thanks, and inside this ImportBefore folder, do you have a file called “SonarQube.Integration.ImportBefore.targets” ?

No. There is no files. All the folders are blank.

Ok, targets are deleted while issuing the “end” step of the comand, so that’s probably normal. If you issue just the begin step and check the folder after, are those files here ?

I missed this from you : “But still getting the same error. Please note that I am doing source code review for .Net Framework “Website””

Please note that we only support .csproj (and some other type of *proj projects) / .sln based projects.

Mickaël