Steps to Send Reports to the Sonar Cloud

According to the docs, the steps to send reports to sonarcloud is…

… dotnet sonarscanner begin
… dotnet build or dotnet test
… dotnet sonarscanner end

But, I woul’d like to maintaing a separate approach like that…

… dotnet sonarscanner begin (to configure and donwload the rules)
… dotnet build (without any code analyzers - this could be the first step, whatever)
… dotnet test (without any code analyzers but generating a report file with the test results)
… dotnet format --verify-no-changes --verbosity m analyzers (generating a report file with the analyzer results)
… dotnet sonarscanner end (to sending the test and code analyzer reports to sonarcloud)

Is it possible to reproduce this scenario this way?

Hey there.

It’s not possible – among other reasons (I don’t know if the Scanner for .NET would even inject the analyzers properly, or if the report would be picked up bgy the scanner) , dotnet format only reports fixable analyzer diagnostics, of which only 60 SonarCloud rules for .NET would qualify right now out of hundreds.

If you run the command “sonarscanner begin” the . ruleset files are downloaded, in this case the command “dotnet format --verify-no-changes --verbosity m analyzers” will read the .ruleset files for validation, being the same validation that " dotnet build" or “dotnet test” does, in this case the only thing that doesn’t happen is the collection by sonarscanner.

In my case the sonar approach forces me to have only one wotkflow running “dotnet tests” to run code analysis and coverage configured tests at the same time, after that sonnarscanner can send the reports with “sonnarscanner end”, but this in my opinion is bad because it is not flexible enough to separate the actions without having to repeat one thing or another.