We have a .NET 5 web app which is built using Azure DevOps and we are using SonarQube to analyze the source code. However, with this project, SonarQube is not analyzing .cs files. This files are just shown as: “Lines of code —”.
.cshtml, css, js, etc files are analyzed and correct number of lines shown.
We are using the SonarQube plugin for Azure Devops.
Any suggestion on why .cs files are not picked up?
@ganncamp thanks for the link but I don’t think so. We are using The Azure DevOps SonarQube which according to the docs: “Since version 5.0, the SonarScanner for MSBuild is now the SonarScanner for .NET.” So we are indeed using SonarScanner for .NET by using the MSBuild option.
I just tried running SonarScanner locally against this project to rule out any Azure DevOps issues and it’s the same problem, running this from the docs:
dotnet <path to SonarScanner.MSBuild.dll> begin /k:"project-key" /d:sonar.login="<token>"
dotnet build <path to solution.sln>
dotnet <path to SonarScanner.MSBuild.dll> end /d:sonar.login="<token>"
Another observation: This is related to this specific project, when moving one class over into a repro project it is analyzing the code and detecting duplications, etc. This seems like a bug in SonarQube and this is kind of critical to us as we have developers that cannot finish their tasks before they are able to fix issues found by SonarQube.
As a clarification, the C# code analysis is working - issues are being raised, however we are not generating the necessary metadata for syntax highlighting and metrics. You can see on your Program.cs that you have a code smell. Also, you should see the analysis warnings in the logs - the files do get analyzed.
We are using Azure DevOps to run the SonarScanner on our projects. It seems like this issue is still not fixed when running through DevOps as we still don’t see the metadata in SonarQube.
Do we need to do anything to force DevOps to use the newly released version?