I have a problem to get sonarcloud running.
The build time of msbuild becomes very slow when using the MSBuild scanner.
We are using the rule-sets of sonarcloud (“sonar way”)
I talk about 216 .csproj files in 116 .sln Files.
- Build time without sonarcloud tasks: ~10min
- Build time without SonarQubeExclude and sonarcloud tasks: 1d+
I started to exclude the most of the projecs with <SonarQubeExclude>true</SonarQubeExclude>
and enabled it on26 .csproj files to be scanned. In this case measure the following:
- Build time with sonarcloud tasks: ~1h 10min
The complete log can be found on google drive:
Languages of the repository:
We want to analyse our C# Projects .net 4.5.2 - 4.7.2 and TypeScript code.
the repository looks like this:
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
XML 4382 10804 3891 3693024
C# 4105 119698 166201 834905
JSON 179 6 0 501572
Java 2081 49816 50841 203106
JavaScript 451 30299 63072 159529
SQL 1644 15471 7648 98725
HTML 2593 8575 1643 90395
TypeScript 1172 5299 6377 85663
Maven 414 3828 7046 83406
MSBuild script 294 328 1826 49337
XSD 110 3376 1779 36594
XAML 119 121 55 20849
CSS 48 2814 524 18237
XSLT 13 875 1561 6735
Markdown 15 1297 0 5152
PowerShell 99 1215 2041 3747
LESS 19 416 74 1860
Visual Basic 8 214 444 1044
DOS Batch 80 182 273 723
YAML 19 129 90 710
Razor 13 33 8 594
Puppet 5 69 4 330
Bourne Shell 6 53 92 106
DTD 1 1 1 76
make 2 28 8 72
ASP.NET 7 2 0 37
Handlebars 9 6 4 35
C++ 1 8 0 35
Objective C++ 1 0 0 34
Sass 1 3 0 17
CoffeeScript 1 1 0 11
F# Script 1 3 0 10
C/C++ Header 1 3 0 9
Pascal 1 10 34 7
Groovy 1 11 41 0
-------------------------------------------------------------------------------
SUM: 17896 254994 315578 5896686
-------------------------------------------------------------------------------
CI system
Azure DevOps with VS2017-Win2016 agents
Build Defintion
this is the azure build definition
trigger:
branches:
include:
- master
- develop
- release/*
variables:
#build version
major: 19
minor: 8
# creates a counter called versioncounter and seeds it at 100 and then assigns the value to a variable named patch.
patch: $[counter('versioncounter', 100)]
# c# Settings
solutions: './**/*.sln'
BuildPlatform: 'Any CPU'
BuildConfiguration: 'Release'
name: $(Date:yyyyMMdd).$(patch)
jobs:
- job: SonarBuild
timeoutInMinutes: 0
pool:
vmImage: 'VS2017-Win2016'
steps:
- task: NuGetToolInstaller@0
- task: SonarCloudPrepare@1
inputs:
SonarCloud: 'XXX'
organization: 'XXX'
scannerMode: 'MSBuild'
projectKey: 'XXX'
projectName: 'XXX'
projectVersion: '$(Build.BuildNumber)'
extraProperties: |
# Additional properties that will be passed to the scanner,
# Put one key=value per line, example:
# sonar.exclusions=**/*.bin
# https://sonarcloud.io/documentation/analysis/analysis-parameters/
# the parameters below are ignored. set directly in sonarcloud.io
# sonar.sources=$(System.DefaultWorkingDirectory)\CrmSchweiz\Source
# sonar.inclusions=**\*.cs
# sonar.exclusions=.\DomainModel\**\*
sonar.verbose=true
sonar.projectKey=XXX
- task: NuGetCommand@2
displayName: 'Restore Nugets'
inputs:
restoreSolution: '$(solutions)'
vstsFeed: 'XXX-Packages'
- task: VSBuild@1
inputs:
solution: '$(solutions)'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
logProjectEvents: false
continueOnError: true
- task: VSTest@2
displayName: 'Unit-Tests'
inputs:
testAssemblyVer2: |
**\$(BuildConfiguration)\*test*.dll
!**\obj\**
testFiltercriteria: 'TestCategory!="IntegrationTest"'
testRunTitle: 'UNIT-Tests'
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
codeCoverageEnabled: true
continueOnError: true
- task: SonarCloudAnalyze@1
- task: SonarCloudPublish@1
inputs:
pollingTimeoutSec: '300'
Question
Why is the build that slow and how can I improve the performance