We have an integration with SonarCloud & Azure Devops. Build times for a solution of aprox 200K lines of code is really slow with SonarQube.
We have the 4 steps for SonarQube as part of our pipeline: Prepare, VSBuild, Test Run, Analysis and Publish.
The SonarCloud Analysis takes 5 min which is ok. We are trying to figure out why VSBuild task with SonarCloud enabled takes 16 min, instead of 2 min without SonarCloud.
The reason for that is that, for .Net languages (C# and VB.Net) the static code analysis rules are run for most part in the VSBuild phase. The final step (that you call SonarCloud analysis) only performs a small fraction of the overall work.
So it’s normal that when you include the SonarCloud scan in your pipeline, the VSBuild step takes more time. You can consider that the delta between the run with and without SonarCloud (16 - 2 = 14 minutes) is the time taken for the execution of the SonarCloud rules… and 14 minutes for 200K LoC is within expectations.
The only way to improve this would be to run SonarQube on a more powerful Azure DevOps agent.