Sonarscanner with ASP .Net Core 3.1 web application

Using SonarQube Community 9.0.1.46107, with SonarScanner for .NET 5.2.2
I’m trying to analyze a .Net Core 3.1 solution.
For class libraries no problem roslyn analysis are uploaded to sonarqube server and the metrics (lines of code, comment size…) are ok
But with asp .net mvc websites metrics are ignoring csharp files! Only css, js… are used! But roslyn analysis are integrated!

I’ve tried with a fresh standalone asp .net core webapp with default visual studio template. Same problem! .cs files are seen as metadata files and not code files!

Typed commands (in root solution folder)

dotnet D:\sonarbuild\sonarscanner.MSBuild.dll begin /k:"sonarweb" /d:sonar.login="xxx" /d:sonar.nodejs.executable="C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VisualStudio\NodeJs\node.exe" /d:sonar.verbose=true
dotnet build /t:Rebuild /P:Configuration=Release
dotnet D:\sonarbuild\sonarscanner.MSBuild.dll end /d:sonar.login="xxx"

Please find attached debug files and configuration files

sonar.begin.txt (6 KB)
sonar.build.txt (1.5 KB)
sonar.end.txt (62.6 KB)

SonarQubeAnalysisConfig.txt (11.7 KB)
sonar-project.properties.txt (7.3 KB)
FilesToAnalyze.txt (9.4 KB)

Thanks for your help, my metrics are completely messed up!

Hello @adlionel

It seems to me that the problem you described is this known issue. It got fixed a few days ago and will be part of the next SonarScanner for .NET release.

Indeed, SonarScanner for .Net 5.3.1 solved this. Now time to reduce technical debt!

Thank you

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.