C# slow build times on SonarCloud

You can read about our plan to address the specific case we found in that reproducer in this comment. No ETA for all the fixes, there are multiple steps to tame the perf problem and we will deliver incrementally.

However, I suggest to share with us the logs in order to see if its the same problem on your side, or something different. The fixed outlined above may not work for your specific case.

To see which rules take time please run msbuild /p:reportanalyzer=true /v:d > build.log

(I will split the topic into a new one, according to our guideline)

RE: building again when running unit tests.

Using the --no-build parameter when calling dotnet test should avoid building again (and running again the Roslyn analysis) during test phase. See dotnet test command - .NET CLI | Microsoft Docs

Please bear in mind that all Roslyn analyzers (ours included) are called during build and the analysis will execute every time the build is done.

You can read a comment on a similar situation here: .NET analysis time during msbuild increased from 15 min to 40+ min - #13 by Andrei_Epure