Not able to scan C# project

Hi Team,

We are using SonarQube 9.9 LTS Version.

We have deployed our Sonar By Zip.

We want to execute SonarQube for C# project.

We have executed below commands and using C# scanner but we are getting error in below last command as “The SonarScanner for MSBuild was failed:SonarQube was unable to collect the required information about your projects”
Commands we used:
SonarScanner.MSBuild.exe begin /k:“eI.” /d:sonar.host.url=“” /d:sonar.login=“”

MsBuild.exe /t:Rebuild /p:Configuration=Release /p:Platform=“x64”

SonarScanner.MSBuild.exe end /d:sonar.login=“”

Note: In the Developer system java 17 is installed for .net sonarscanner 4.7
Could you please check and let us know the possible resolution for the above issue?

Thanks in advance.
Regards,
Huzaifa Siddiqui.

Hey there.

Can you share the full logs from all these steps?

If correct, this is a pretty old version of the SonarScanner for .NET (from September 2019). Can you try with v6.0, the latest version?

Hi Colin,

We have updated the Latest sonar Scanner as you suggested, but still getting the same error.

Attaching the full logs below:
D:\Projects\Propel\New ADO Repos>MSBuild.exe D:\Projects\Propel\New ADO Repos /t:Rebuild
Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

MSBUILD : error MSB1008: Only one project can be specified.
Switch: ADO

For switch syntax, type “MSBuild -help”

D:\Projects\Propel\New ADO Repos>SonarScanner.MSBuild.exe end /d:sonar.login=“”

SonarScanner for MSBuild 6.0

Using the .NET Framework version of the Scanner for MSBuild

Post-processing started.

16:58:58.541 The SonarScanner for 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.25420.1 and higher 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)

16:58:58.542 Generation of the sonar-properties file failed. Unable to complete the analysis.

16:58:58.543 sonar-project.properties files are not understood by the SonarScanner for MSBuild. Remove those files from the following folders: D:\Projects\Propel\New ADO Repos

16:58:58.544 Post-processing failed. Exit code: 1

Thanks & Regards,
Huzaifa Siddiqui

Well, here’s the issue.

You need to point to a specific solution, not a directory (here: MSBuild.exe D:\Projects\Propel\New ADO Repos)

Hi Colin,

We have changed as you suggested from directory to a specific solution, but now we are getting another below error:

C:\Program Files\dotnet\sdk\3.1.426\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(241,5)
: error NETSDK1005: Assets file ‘D:\Projects\pr\New ADO Repos\pr-assetmanagement\pr.AssetManagement.Service
\obj\project.assets.json’ doesn’t have a target for ‘.NETFramework,Version=v6.0’. Ensure that restore has run and that
you have included ‘net60’ in the TargetFrameworks for your project. [D:\Projects\pr\New ADO Repos\pr-assetmanag
ement\pr.AssetManagement.Service\pr.AssetManagement.Service.csproj]

Note: We have checked, the target .net version is also same as installed .net version.

Thanks in advance,
Huzaifa Siddiqui.

At this point, this is an issue with your build, not with SonarQube (you would face the same issue trying to build your code without SonarQube). Unfortunately I won’ t able to help you get your code compiling – but once it compiles correctly, if you still face issues with SonarQube integration let us know!

Hi Colin,

Thank you for your prompt response and suggestions!

We will check if there is any build issue from our side.

Meanwhile, It will be really helpful if you can confirm that .net 6.0 framework version is supported with SonarQube 9.9 LTS version?

Thanks in advance!
Regards,
Huzaifa Siddiqui.

Yes, it is supported.