Facing issue on Scanning C# code for Classic .net project through SonarQube

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension): SonarQube -6.7, SonarScanner for MS Build - 4.2, Plugin SonarC3-6.5
  • what are you trying to achieve - I am trying to scan my C# code

Unfortunately my C# code is not getting scanned. I am following below command and attached the log for the END command.

SonarScanner.MSBuild.exe begin /k:“Project-Key”
MSBuild.exe /t:Rebuild
SonarScanner.MSBuild.exe end
LogClassic.txt (27.8 KB)

Please help me on this.

The Source Paths in your logs makes it appear like the only code inside is SQL code. What C# code do you expect to appear?

We have whole project written in c# code. So there is lots of C# code which are not being scanned.

Anyone please help me on this

First of all, please update the scanner for msbuild to the latest version - 4.8

Second, please answer the following questions:

  • what is the version of MSBuild you are using?

  • are you running all commands from the same folder?

  • please upload the debug logs for all the steps - BEGIN, BUILD and END ; to get the debug log add /d:sonar.verbose=true to the begin step (e.g. SonarScanner.MSBuild.exe begin /k:"MyProject" /d:sonar.verbose=true as the begin step, and please attach the output of END step)

  • could you please share the .sonarqube\conf\SonarQubeAnalysisConfig.xml and the .sonarqube\conf\sonar-project.properties

Thanks Andrei,
Actually I have installed the Sonar-scanner for MS Build which is compatible to SonarQube - 6.7 .
MSBUild version - 15
Yes, I am running all the command from the root of the project.

Now I am getting below error in the end command:
ERROR: File Program.cs can’t be indexed twice. Please check that in
clusion/exclusion patterns produce disjoint sets for main and test files

Hi Andrei,
Is it possible to have a talk with you directly. I have to necessarily solve it. Not able to debug.
Today I created a new small project and here its not showing any error. But not able to scan the code.
Attached the recent logs here.log1.txt (46.8 KB)

hey @Abinash

  • what are the commands that you are running?
    – have you followed the instructions on https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-msbuild/ ?
  • please also upload the verbose logs from the msbuild command ( msbuild /v:d ... )
  • could you please share the .sonarqube\conf\SonarQubeAnalysisConfig.xml and the .sonarqube\conf\sonar-project.properties (these are generated in the folder where you run the commands in)