Unable to scan C# code

Must-share information:

  • which versions are you using - SonarQube community version 8.5.1 (build 38104).
  • what are you trying to achieve - Scan C# code
  • what have you tried so far to achieve this - Created a new project and followed steps to scan the C# code

The sonarqube dashboard shows the following commands:

I tried the following commands:

Please let me know what I need to change in order to scan the code.

Hey there.

It’s pretty clear from the logs that MSBuild.exe was not recognized. Is it installed on your machine, and are you executing it from a folder with a Visual Studio solution?

Hi Colin,

I am sure that I am executing the command from the folder where the VS solution lies.
I have no idea about MSBuild.exe, as it’s not present anywhere inside the solution folder and neither in the scanner downloaded. Can you please help me with the same?

Let’s step back and ask another question – how do you compile your C# code on this machine? The MSBuild.exe represents a command used to compile your C# project/solution – it is, strictly speaking, quite separate from the topic of running SonarQube analysis, but compiling your C# code is necessary in the process to analyze your C# code.

I don’t want to compile the code on my machine when the activity is of code review instead of code development.
Actually, why would the code need to built on a tester’s machine performing the secure code review for the code written by the developer?

The way we have implemented analysis for C# requires a compilation to take place (it’s where the analyzers actually run!). This is true for most of the compiled languages we support (Java, C#, C and C++). Other languages don’t share this same requirement.

When used most effectively we expect SonarQube analysis to run as a part of the CI/CD process (where the build is happening already), not as a separate process (stated another way – we don’t expect Testers to manually run SonarQube analysis). Take a peek at the homepage of our docs

It was brought to my attention you can also find the tutorial on an existing project by popping over to the Administration > Analysis Method section of your project :smiley:

Sorry to say, but this doesn’t help our cause :frowning:

Whoops, that last comment was meant for another topic :man_facepalming: