C# project Sonarqube from local code

Need to test from sonarQube tool for c# code from the local machine.

Kindly suggest the steps. I have tried many ideas blocking with MSBuild.

Step by step configuration SonarQube for C# code.

Hi Yasin,

Welcome to our community. Do you have already the SonarQube running?

If yes, you can follow the steps described here: https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-msbuild

Please let us know how it’s going or if there are any impediments.

Thanks Costin,

I have followed already in the shared link. In my system I have Visual studio 2017. I have tried excuting from the project sln file path with command prompt following 3 execution scripting step . It saying MSbuild un-identifiable. Suggest any video link possible .net code using sonarqube.

Yasin T

Hi Yasin,

Would it be possible to post here the commands and the error message you got?

Thanks Costin,

Suggested sonarQube steps for .net
Step 1 :
SonarScanner.MSBuild.exe begin /k:“DiscA” /d:sonar.host.url=“http://localhost:9000” /d:sonar.login=“200642ffca7c24105c62733fefb3f801af3591a3”
Step 2 :
MsBuild.exe /t:Rebuild
Step 3 :
SonarScanner.MSBuild.exe end /d:sonar.login=“200642ffca7c24105c62733fefb3f801af3591a3”

I Opend in the .Net solution folder -> cmd prompt executed the suggested commands.
Microsoft Windows [Version 6.1.7601]
Copyright © 2009 Microsoft Corporation. All rights reserved.

C:\DiscAA\DiscA-Source-EPSW>SonarScanner.MSBuild.exe begin /k:“DiscA” /d:sonar.h
ost.url=“http://localhost:9000” /d:sonar.login=“200642ffca7c24105c62733fefb3f801
‘SonarScanner.MSBuild.exe’ is not recognized as an internal or external command,
operable program or batch file.
C:\Project\Project-Source-EPSW>MsBuild.exe /t:Rebuild
‘MsBuild.exe’ is not recognized as an internal or external command,
operable program or batch file.
C:\Project\Project-Source-EPSW>SonarScanner.MSBuild.exe end /d:sonar.login=“200642f
‘SonarScanner.MSBuild.exe’ is not recognized as an internal or external command,
operable program or batch file.

The problem seems to be that the correct path to the scanner is not provided. If you haven’t already, please download the MsBuild scanner from here

Then, unzip the file in a new folder (e.g. C:\tools\sonar-scanner), and run the commands using the full path (e.g. C:\tools\sonar-scanner\SonarScanner.MSBuild.exe). Optionally, you can add the folder to the PATH in system environment variables.

Similarly, for MsBuild, you should use the full file path or use the Developer command prompt.

Thanks Reply and Support Costin.

I have executed using these commands it worked fine.
dotnet sonarscanner begin /k:“52d4bad7605eef4b596b8c93a5a8ee85e92cf0a8”
dotnet build C:\Project\Project-Source-EPSW\ProjectA.sln
dotnet sonarscanner end .

I need a clarification further i need check from Azure branch code.
is this licensed?

Hi Yasin,

If you need to analyze feature and maintenance branches you will have to upgrade to the developer edition. You can see here the main differences: https://www.sonarqube.org/downloads/

Thanks for the suggestion Costin any further queries i will reach you.