Does SonarCloud have an impact on build time?

Hi All :slight_smile:
We’re using ADO with Git repositories.
All code is in C#.
We noticed very strange behavior. Same pipelines, the difference between them is that in one we have tasks from SonarCloud in the other not.
The Build task and Unit Test task times are very different to the disadvantage of the one with Sonar. Can SonarCloud and its tasks affect the build time of the application?


When I look at your two screenshots, here’s what I see:

step with without
Initialize job <1s <1s
Pre-job BuildQualityChecks :x: 2s
Checkout 26s 16s
Download 3s 4s
Use .NET Core sdk 4s 4s
Restore NuGet Packages 21s 36s
VisualStudioTestPlatformInstaller 4s :x:
SonarCloudPrepare 50s :x:
Build 11m 14s 2m 6s
Run UnitTests 7m 53s 3m 32s
Run IntegrationTests :x: 20s
Download Databaseupgrade pack… :x: 9s
Run database midgrations :x: 1m 13s
SonarCloudAnalyze 20m 51s :x:
SonarCloudPublish 2m 51s :x:
sonarcloudbuildbreaker 3s :x:

From the lack of “VisualStudioTestPlatformIntaller” in the fast job, (as well as differences in a number of other steps) this looks to me like an apples/oranges comparison and not quite “same pipelines”. Analysis may be having some impact on build time, but to what degree is that also affected by VisualStudioTestPlatformInstaller?


I can agree with you that the pipelines are a little different, but it is the same product and it seems that pre-build tasks should not have any impact on the build time. The computers on which the build goes are the same, so the times should also be the same or close, and here the difference is in the hundreds of percent.


The difference in the pipelines, particularly VisualStudioTestPlatformInstaller, makes me really wonder if the same build configuration is used in both. I.e. if the difference in the build time isn’t intrinsic. Would it be possible to a real apples-to-apples comparison?


Hi Ann,
We have made the changes you wrote about and this step that raised your concerns is irrelevant. Build with SonarCloud enabled extends the build time.
Maybe some information during the build is sent to SonarCloud servers?


Data to SonarCloud is only sent at the end. It’s possible some data is requested, but I think that actually all happens during the ‘Prepare’ step.

I’m going to flag this for more expert eyes.


1 Like

Hello @bartoszrichert,

The SonarCloudPrepare step instruments the msbuild to run our rules during the build. This results in an increase in build time. In your case, the build time increased by factor 6 which is quite high and slightly above what we usually see as an increment.
It is suspicious that the Run UnitTests task also doubles in duration. Our rules only run during build. In case Run UnitTests does no compilation but uses the artifacts from the build step you shouldn’t see this increase.
Can you please run the steps (SonarCloudPrepare, Build, Run UnitTests, SonarCloudPrepareAnalyze, and SonarCloudPreparePublish) with verbose logging and send us the logs?

Best, Martin

Share the Scanner for .NET verbose logs

  • Add /d:"sonar.verbose=true" to the…
    • SonarScanner.MSBuild.exe or dotnet sonarscanner begin command to get more detailed logs
      • For example: SonarScanner.MSBuild.exe begin /k:"MyProject" /d:"sonar.verbose=true"
    • “SonarQubePrepare” or “SonarCloudPrepare” task’s extraProperties argument if you are using Azure DevOps
      • For example:
        - task: SonarCloudPrepare@1
              SonarCloud: 'sonarcloud'
              organization: 'foo'
              scannerMode: 'MSBuild'
              projectKey: 'foo_sonar-scanning-someconsoleapp'
              projectName: 'sonar-scanning-someconsoleapp'
              extraProperties: |
  • The important logs are in the END step (i.e. SonarQubeAnalyze / SonarCloudAnalyze / “Run Code Analysis”)

Share the msbuild detailed logs

MsBuild.exe /t:Rebuild /v:d


dotnet build -v:d
08:08:27.242 Creating directory: D:\Agent1\_work\1\.sonarqube\out

08:08:27.273 Downloading from

08:08:27.445 SonarCloud detected, skipping license check.

08:08:27.445 Fetching analysis configuration settings...

08:08:27.46 Fetching properties for project XXXXXXXXX-backend' from

08:08:27.46 Downloading from

08:08:27.538 Downloading from

08:08:27.57 Fetching quality profile for project 'XXXXXXXXX-backend' from

08:08:27.57 Downloading from

08:08:27.679 Fetching rules for quality profile 'ZZZZZZZZZZZ' from,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=ZZZZZZZZZ=1...

08:08:27.679 Downloading from,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=ZZZZZZZZ=1...

08:08:27.882 Local analyzer cache: C:\Users\adosvc\AppData\Local\Temp\.sonarqube\resources

08:08:27.882 Writing Roslyn generated ruleset to D:\Agent1\_work\1\.sonarqube\conf\Sonar-cs.ruleset...

08:08:27.913 Writing Roslyn generated ruleset to D:\Agent1\_work\1\.sonarqube\conf\Sonar-cs-none.ruleset...

08:08:27.913 Provisioning analyzer assemblies for cs...

08:08:27.913 Installing required Roslyn analyzers...

08:08:27.929 Processing plugin: csharp version

08:08:28.07 Cache hit: using plugin files from C:\Users\adosvc\AppData\Local\Temp\.sonarqube\resources\17

08:08:28.07 Processing plugin: vbnet version

08:08:28.085 Cache hit: using plugin files from C:\Users\adosvc\AppData\Local\Temp\.sonarqube\resources\18

08:08:28.085 Processing plugin: securitycsharpfrontend version 9.8.0-M2.18467

08:08:28.085 Cache hit: using plugin files from C:\Users\adosvc\AppData\Local\Temp\.sonarqube\resources\19

08:08:28.085 Writing Roslyn analyzer additional file to D:\Agent1\_work\1\.sonarqube\conf\cs\SonarLint.xml...

08:08:28.085 Fetching quality profile for project 'XXXXXXXXXXX-backend' from

08:08:28.085 Downloading from

08:08:28.179 Fetching rules for quality profile 'ZZZZZZZZZZ' from,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=ZZZZZZZZZZZZZ=1...

08:08:28.179 Downloading from,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=ZZZZZZZZZZZZZ=1...

08:08:28.257 Local analyzer cache: C:\Users\adosvc\AppData\Local\Temp\.sonarqube\resources

08:08:28.257 Writing Roslyn generated ruleset to D:\Agent1\_work\1\.sonarqube\conf\Sonar-vbnet.ruleset...

08:08:28.257 Writing Roslyn generated ruleset to D:\Agent1\_work\1\.sonarqube\conf\Sonar-vbnet-none.ruleset...

08:08:28.257 Provisioning analyzer assemblies for vbnet...

08:08:28.257 Installing required Roslyn analyzers...

08:08:28.257 Processing plugin: csharp version

08:08:28.257 Cache hit: using plugin files from C:\Users\adosvc\AppData\Local\Temp\.sonarqube\resources\17

08:08:28.257 Processing plugin: vbnet version

08:08:28.257 Cache hit: using plugin files from C:\Users\adosvc\AppData\Local\Temp\.sonarqube\resources\18

08:08:28.273 Writing Roslyn analyzer additional file to D:\Agent1\_work\1\.sonarqube\conf\vbnet\SonarLint.xml...

08:08:28.304 Pre-processing succeeded.

Finishing: SonarCloudPrepare

Hello @bartoszrichert

can you please also provide the logs from the end step and the build logs?

Best Martin

Hi @Martin_Strecker ,
I sent it by email to Emre.


Hi Bartek,

You’re always welcome to redact sensitive details from anything you post here, but if you really feel the need, @Martin_Strecker can create a private thread where you can share your logs privately.