Not able to scan C# projects on SonarQube

Hello Team,

Good Day !!

We are using SonarQube Version 9.2.4, and Sonar-Scanner 4.6.2.
We are trying to execute the C# project on SonarQube and If we are running the project, only 30-40% of C# files are scanned.

We have downloaded the sonar scanner for MSBuild from the below link:
and try to scan c# projects but got different build errors.
Also, we have solved build errors and scanned the C# project but the total project has not been analyzed.

Is it possible to scan the C# project without MSBuild and scan by sonar-scanner 4.6.2?

Please help here.

Thank you,
Akash Chavan

Hey there,

You must use the Scanner for .NET in order to analyze C# code. It’s not possible to use the SonarScanner CLI.

Is there any particularly interesting warning/errors in the build logs or analysis logs (the logs triggered by running msbuild or dotnet, as well as the end task for SonarScanner for .NET.

Most often, when users report that only a subset of their C# is being analyzed, it’s because something has gone wrong with the detection of test projects.

Hello Colin,

Good Day !!

Sorry for the delay in response.

For the reported issue, Issue: When the build is executed as part of GUI sonar Qube execution, it is not setting the correct processor architecture and build is failing.
And SonarQube execution ends with failure.
When we build the same project from Visual Studio there are no errors, and the build is completed successfully.
Additional Note:
SonarScanner used for MSBuild 5.5.3
Using the .NET Framework version of the Scanner for MSBuild.

I am attaching the log of the build error.

Looking forward to your cooperation and support.
sonar-Qube-error-june-2022.txt (30.6 KB)

Thanks & Regards,
Akash Chavan

Hey there.

If MsBuild.exe /t:Rebuild /P:configuration=Release is resulting in a failed build (taking the SonarScanner for .NET out of the picture entirely), you’re going to have to figure out why that is and then add in the SonarQube steps.

We won’t be able to help you troubleshoot the build itself (even if it works in Visual Studio, but isn’t working on the command line). For that, you’ll have to debug, or reach out to Microsoft support communities.