Hi All
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?
Hi,
When I look at your two screenshots, here’s what I see:
step | with | without |
---|---|---|
Initialize job | <1s | <1s |
Pre-job BuildQualityChecks | ![]() |
2s |
Checkout | 26s | 16s |
Download | 3s | 4s |
Use .NET Core sdk | 4s | 4s |
Restore NuGet Packages | 21s | 36s |
VisualStudioTestPlatformInstaller | 4s | ![]() |
SonarCloudPrepare | 50s | ![]() |
Build | 11m 14s | 2m 6s |
Run UnitTests | 7m 53s | 3m 32s |
Run IntegrationTests | ![]() |
20s |
Download Databaseupgrade pack… | ![]() |
9s |
Run database midgrations | ![]() |
1m 13s |
SonarCloudAnalyze | 20m 51s | ![]() |
SonarCloudPublish | 2m 51s | ![]() |
sonarcloudbuildbreaker | 3s | ![]() |
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?
Ann
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.
BR
Bartek
Hi,
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?
Ann
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?
Hi,
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.
Ann
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
ordotnet sonarscanner
begin command to get more detailed logs- For example:
SonarScanner.MSBuild.exe begin /k:"MyProject" /d:"sonar.verbose=true"
- For example:
- “SonarQubePrepare” or “SonarCloudPrepare” task’s
extraProperties
argument if you are using Azure DevOps- For example:
- task: SonarCloudPrepare@1 inputs: SonarCloud: 'sonarcloud' organization: 'foo' scannerMode: 'MSBuild' projectKey: 'foo_sonar-scanning-someconsoleapp' projectName: 'sonar-scanning-someconsoleapp' extraProperties: | sonar.verbose=true
- For example:
-
- 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
or
dotnet build -v:d
08:08:27.242 Creating directory: D:\Agent1\_work\1\.sonarqube\out
08:08:27.273 Downloading from https://sonarcloud.io/api/server/version...
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 https://sonarcloud.io/api/settings/values?component=XXXXXXXXXXX-backend...
08:08:27.46 Downloading from https://sonarcloud.io/api/settings/values?component=XXXXXXXX-backend...
08:08:27.538 Downloading from https://sonarcloud.io/api/languages/list...
08:08:27.57 Fetching quality profile for project 'XXXXXXXXX-backend' from https://sonarcloud.io/api/qualityprofiles/search?project=XXXXXXXXX-backend&organization=YYYYYY...
08:08:27.57 Downloading from https://sonarcloud.io/api/qualityprofiles/search?project=XXXXXXXXX-backend&organization=YYYYYYY...
08:08:27.679 Fetching rules for quality profile 'ZZZZZZZZZZZ' from https://sonarcloud.io/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=ZZZZZZZZZ=1...
08:08:27.679 Downloading from https://sonarcloud.io/api/rules/search?f=repo,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 8.49.0.57237
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 8.49.0.57237
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 https://sonarcloud.io/api/qualityprofiles/search?project=XXXXXXXXXXXXXX-backend&organization=YYYYYY...
08:08:28.085 Downloading from https://sonarcloud.io/api/qualityprofiles/search?project=XXXXXXX-backend&organization=YYYYYY...
08:08:28.179 Fetching rules for quality profile 'ZZZZZZZZZZ' from https://sonarcloud.io/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=ZZZZZZZZZZZZZ=1...
08:08:28.179 Downloading from https://sonarcloud.io/api/rules/search?f=repo,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 8.49.0.57237
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 8.49.0.57237
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 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.
Ann