Enabling SonarCloud in Az-DevOps pipeline cause dotnet unit test to be slow

Hi @planbsim

thanks for the well written, detailed topic.

The first thing is to make sure you do the build only once (you can read similar advice here and more recently here). If you build multiple times, the Roslyn analysis will run multiple times, and that’s not necessary. Using the --no-build parameter when calling dotnet test should avoid building again during test phase. See dotnet test command - .NET CLI | Microsoft Docs .

From the logs, I cannot see big outliers. One analysis takes 166 seconds, probably that project is bigger (see lines 16771-16778). For CollectionQuerySimplification we have a ticket to improve, you can see the perf improvements backlog we have.

If you only do the analysis once, during the build, and don’t do it again for unit test run and integration test run, you’ll save a lot of time. This is what we do in our pipeline.