C# slow build times on SonarCloud

Does this mean it should be solved in the mean time? Or is it still a work in progress?

I’m running into the same issue while trailing SonarCloud for our projects.

Both the builds and the tests increased a lot in runtimes. The build used to be ~50 seconds and now it’s 15 minutes. I expected some increase but this is way beyond what I expected it to be.

Executing the unit tests went from 4 mins to 16 mins.

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

Hi @Andrei_Epure

Thanks for your help so far!

I had tried the --no-build parameter before, but it immediately broke my the dotnet test command. I reverted it without looking into the issue. Today I took a closer look into what was happening and it turned out I had to resolve some more issues to get it to work.

Initial results look good, as it speeds up the unit test execution a lot.

I’ll try to gather some logs and share those with you as well. Hopefully, they can give you some more insights. What would be the best way to share those files with you?

Update: I just also noticed that the CPU usage on our build agent heavily increased after adding code coverage calculation and enable the sonarcloud analysis. This high CPU usage also seems to cause slowing down the builds.

Yes, and maybe monitor the RAM usage, too. You main want to upgrade the configuration to get better perf.

I’ll send you a private message.