SonarQube MSBuild integration failed

Hello @Andrei_Epure ,
I have the same issue than @amol.karekar with a .net core project, can you help please ?
FYI: I’m using sonarqube on docker.
I’ve built the project between begin and end steps, all steps (begin, build, end) has been launched from the same folder.
CMD1

dotnet sonarscanner begin /k:“projectkey” /d:sonar.host.url=“http://localhost:9000” /d:sonar.login=“myprojectkey”
Output:
SonarScanner for MSBuild 4.3.1
Using the .NET Core version of the Scanner for MSBuild
Default properties file was found at C:\Users\myuser.dotnet\tools.store\dotnet-sonarscanner\4.3.1\dotnet-sonarscanner\4.3.1\tools\netcoreapp2.1\any\SonarQube.Analysis.xml
Loading analysis properties from C:\Users\myuser.dotnet\tools.store\dotnet-sonarscanner\4.3.1\dotnet-sonarscanner\4.3.1\tools\netcoreapp2.1\any\SonarQube.Analysis.xml
Pre-processing started.
Preparing working directories…
21:15:06.975 Updating build integration targets…
21:15:07.022 Fetching analysis configuration settings…
21:15:08.517 Provisioning analyzer assemblies for cs…
21:15:08.519 Installing required Roslyn analyzers…
21:15:09.114 Provisioning analyzer assemblies for vbnet…
21:15:09.115 Installing required Roslyn analyzers…
21:15:09.136 Pre-processing succeeded.

CMD2

dotnet build .\Orchestrator.sln

Build succeeded.

CMD3

dotnet sonarscanner end /d:sonar.login=“myprojectkey”
SonarScanner for MSBuild 4.3.1
Using the .NET Core version of the Scanner for MSBuild
Default properties file was found at C:\Users\myuser.dotnet\tools.store\dotnet-sonarscanner\4.3.1\dotnet-sonarscanner\4.3.1\tools\netcoreapp2.1\any\SonarQube.Analysis.xml
Loading analysis properties from C:\Users\myser.dotnet\tools.store\dotnet-sonarscanner\4.3.1\dotnet-sonarscanner\4.3.1\tools\netcoreapp2.1\any\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 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)
    Generation of the sonar-properties file failed. Unable to complete SonarQube analysis.
    21:16:50.738 Creating a summary markdown file…
    21:16:50.743 Post-processing failed. Exit code: 1

Hi @Fouss

I’ve split your question in a different topic, as this is a good practice on this forum (1 problem - 1 topic, as 2 apparently similar topics might have separate root causes).

Could you please reply to the below questions?

  • which dotnet core version are you targetting?
  • what are the contents of the .sonarqube\out folder?
  • could you please share the .sonarqube\conf\SonarQubeAnalysisConfig.xml and the .sonarqube\conf\sonar-project.properties
  • Is the project that is being skipped listed in the .sonarqube\out\ProjectInfo.log ? (if not then it isn’t being analyzed)
1 Like

Hello @Andrei_Epure,

Thank you for your reply and sorry for this bad practice.

  • I’ve the same issue with dotnet core 2.1, 2.2, 3.0 after executing this command :

dotnet sonarscanner end /d:sonar.login=“b19a6daa1075f071f2fe068cfe411f72aa8cc895”

Any idea, how can i fix this ? Maybe i’ve done something wrong in configurations :crossed_fingers:

1 Like

Try using the latest version of the Scanner for MSBuild (v4.6.x).

The version you are using (v4.3.1) doesn’t support MSBuild v16; the latest version does.

2 Likes

Hi @duncanp,
Indeed the problem was related to dotnet-sonarscanner version 4.3.1 instead of latest.
Fixed after upgraded dotnet-sonarscanner version to the latest one (4.6.2) and works like a charm.
Thanks all for your support.

3 Likes

Hi,

i am using sonarqube-7.9.1 community edition and sonar-scanner-msbuild-4.6.2.2108-net46. I created a test projects in VS2017 in .Net4.5 framework.

I am facing the issues , while executing the the last steps command - SonarScanner.MSBuild.exe end

Step1:
SonarScanner.MSBuild.exe begin /k:“sonarqubetest” /d
:sonar.host.url=“http://localhost:9000” /d:sonar.login=“mykey”
SonarScanner for MSBuild 4.6.2
Using the .NET Framework version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories…
16:44:33.756 Updating build integration targets…
16:44:33.842 Fetching analysis configuration settings…
16:44:36.007 Provisioning analyzer assemblies for cs…
16:44:36.01 Installing required Roslyn analyzers…
16:44:37.142 Provisioning analyzer assemblies for vbnet…
16:44:37.143 Installing required Roslyn analyzers…
16:44:37.228 Pre-processing succeeded.

Steps 2:

My MSBuild is in different drive
MsBuild.exe /.sln /t:Rebuild

Build Succeeded.
Step 3:
switch to .net solution directory:

<solutionDir> SonarScanner.MSBuild.exe end /d:sonar.login="mykey"
SonarScanner for MSBuild 4.6.2
Using the .NET Framework version of the Scanner for MSBuild
Post-processing started.
The SonarQube MSBuild integration failed: SonarQube was unable to collect the re
quired information about your projects.
Possible causes:
  1. The project has not been built - the project must be built in between the b
egin and end steps
  2. An unsupported version of MSBuild has been used to build the project. Curre
ntly MSBuild 14.0 and 15.0 are supported
  3. The begin, build and end steps have not all been launched from the same fol
der
  4. None of the analyzed projects have a valid ProjectGuid and you have not use
d a solution (.sln)
Generation of the sonar-properties file failed. Unable to complete SonarQube ana
lysis.
16:45:55.245  Post-processing failed. Exit code: 1

Could you please help me, is anything i am doing wrong. i have latest.

Did you launched all three steps in the same folder as point out in possible causes ? If not you have to.

Step 2 - build has executed in different folder as there is no MSBuild.exe in my test project solution directory.

E:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin>
MsBuild.exe D:\SampleProjects\sonartest\sonartest.sln /t:Rebuild

As per instruction, execution of begin part is working, when i tried to execute build part,
the message show
’MsBuild.exe’ is not recognized as an internal or external command,
operable program or batch file.

D:\SampleProjects\sonartest>SonarScanner.MSBuild.exe begin /k:“sonarqubetest” /d
:sonar.host.url=“http://localhost:9000” /d:sonar.login=“257c8dbc35aeae823b8cf752
fb803d03106af2c4”
SonarScanner for MSBuild 4.6.2
Using the .NET Framework version of the Scanner for MSBuild
Pre-processing started.
Preparing working directories…
10:58:28.117 Updating build integration targets…
10:58:28.196 Fetching analysis configuration settings…
10:58:30.392 Provisioning analyzer assemblies for cs…
10:58:30.392 Installing required Roslyn analyzers…
10:58:31.47 Provisioning analyzer assemblies for vbnet…
10:58:31.47 Installing required Roslyn analyzers…
10:58:31.533 Pre-processing succeeded.

D:\SampleProjects\sonartest>MsBuild.exe /t:Rebuild
’MsBuild.exe’ is not recognized as an internal or external command,
operable program or batch file.

D:\SampleProjects\sonartest>

Sorted out the issues.
Thanks

You have to add scanner for msbuild to your PATH environment variable in order to avoid this kind of error and use SonarScanner command everywhere. As describe here SonarScanner for MSBuild for .NET Framework

A post was split to a new topic: Problem analysing with Scanner for MSBuild