SonarCloud isn't scanning my entire project

Hi SonarSource Team,

I have a Xamarin.Forms project and I’ve implemented SonarCloud in my DevOps pipeline. The problem I’m having is that SonarCloud seems to only be scanning XML files in one of my folders (Android) and is ignoring my Main and iOS folders:


I would like it to scan the entirety of my VS Solution and include my C# files.

The Problem:

SonarCloud is only analyzing XML files in one folder of my repository, ignoring my other folders and other file types (i.e. C# files).

The Project Details:

My file

# Project identification

# Info required for Sonar 

# Default source code encoding

# Enable the Visual Studio bootstrapper

My DevOps pipeline yml file

# Xamarin
# Build a Xamarin project.
# Add steps that install certificates, test, sign, and distribute an app, save build artifacts, and more:

- master
- develop

- develop

  vmImage: 'macOS-latest'

  - group: build-variables
  - name: buildConfiguration
    value: 'Release'
  - name: outputDirectory
    value: '$(build.binariesDirectory)/$(buildConfiguration)'
  - name: xcodeRoot
    value: '/Applications/'
  - name: sonarCloudEndpointName
    value: 'XXXXX'
  - name: sonarCloudOrganization
    value: 'XXXXX'
  - name: sonarCloudProjectKey
    value: 'XXXXX'
  - name: sonarCloudProjectName
    value: 'XXXXX'

- checkout: self
  lfs: true

- task: SonarCloudPrepare@1
  displayName: 'Prepare analysis configuration'
    SonarCloud: '$(sonarCloudEndpointName)'
    organization: '$(sonarCloudOrganization)'
    scannerMode: 'CLI'
    configMode: 'file'
    configFile: ''

- task: UseDotNet@2
  displayName: 'Use .NET Core sdk'
    packageType: sdk
    version: 2.2.402
    installationPath: $(Agent.ToolsDirectory)/dotnet

# To manually select a Xamarin SDK version on the Microsoft-hosted macOS agent,
# configure this task with the *Mono* version that is associated with the
# Xamarin SDK version that you need, and set the "enabled" property to true.
# See
- script: sudo $AGENT_HOMEDIRECTORY/scripts/ 6_4_0
  displayName: 'Select the Xamarin SDK version'

# Xamarin SDK corresponding to Mono version 6.0.0 or higher (selected in the above step)
# require Xcode 11.0 or higher
- script: echo '##vso[task.setvariable variable=MD_APPLE_SDK_ROOT;]'$(xcodeRoot);sudo xcode-select --switch $(xcodeRoot)/Contents/Developer
  displayName: 'Select the Xcode version'

- task: NuGetToolInstaller@1

- task: NuGetCommand@2
    restoreSolution: '**/*.sln'

- task: android-manifest-version@1
    sourcePath: 'XXXXX/XXXXX.Android/Properties/AndroidManifest.xml'
    versionCodeOption: 'buildid'
    versionCode: '$(Build.BuildId)'
    versionName: '$(version.major).$(version.minor).$(Build.BuildId)'
    printFile: true

- script: cp XXXXX/XXXXX/appsettings-$(ENVIRONMENT).json XXXXX/XXXXX/appsettings.json
  displayName: 'Settings for $(environment)'

- task: XamarinAndroid@1
    projectFile: '**/*.Android.csproj'
    outputDirectory: '$(outputDirectory)'
    configuration: '$(buildConfiguration)'
    jdkOption: 'JDKVersion'
    createAppPackage: true

- task: AndroidSigning@3
    apkFiles: '**/*.apk'
    apksignerKeystoreFile: 'XXXXX.keystore'
    apksignerKeystorePassword: '$(android.keystore.password)'
    apksignerKeystoreAlias: '$(android.keystore.alias)'
    apksignerKeyPassword: '$(android.keystore.aliaspassword)'
    apksignerArguments: '--verbose --out $(outputDirectory)/XXXXX.$(Build.BuildId).signed.apk'
    zipalign: true

- task: AppCenterDistribute@3
  condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
    serverEndpoint: 'XXXXX'
    appSlug: 'XXXXX'
    appFile: '$(outputDirectory)/XXXXX.$(Build.BuildId).signed.apk'
    symbolsOption: 'Android'
    releaseNotesOption: 'input'
    releaseNotesInput: '$(Build.SourceVersionMessage)'
    destinationType: 'groups'

# Install Apple certificate
# Install an Apple certificate required to build on a macOS agent machine
- task: InstallAppleCertificate@2
    certSecureFile: 'XXXXX.p12'
    certPwd: '$(ios.certificate.password)'
    keychain: 'temp'

# Install Apple provisioning profile
# Install an Apple provisioning profile required to build on a macOS agent machine
- task: InstallAppleProvisioningProfile@1
    provisioningProfileLocation: 'secureFiles'
    provProfileSecureFile: 'XXXXX.mobileprovision'

- task: ios-bundle-version@1
    sourcePath: 'XXXXX/XXXXX.iOS/Info.plist'
    versionCodeOption: 'buildid'
    versionCode: '$(Build.BuildId)'
    versionName: '$(version.major).$(version.minor).$(Build.BuildId)'
    printFile: true

- task: XamariniOS@2
    solutionFile: '**/*.iOS.csproj'
    configuration: '$(buildConfiguration)'
    packageApp: true
    runNugetRestore: false
    args: '/p:IpaPackageDir="$(Build.ArtifactStagingDirectory)"'
    signingProvisioningProfileID: '$(APPLE_PROV_PROFILE_UUID)'

- task: AppCenterDistribute@3
  condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master'))
    serverEndpoint: 'XXXXX'
    appSlug: 'XXXXX'
    appFile: '$(Build.ArtifactStagingDirectory)/*.ipa'
    symbolsOption: 'Apple'
    releaseNotesOption: 'input'
    releaseNotesInput: '$(Build.SourceVersionMessage)'
    destinationType: 'groups'

- task: SonarCloudAnalyze@1
  displayName: 'Run SonarCloud analysis'

- task: SonarCloudPublish@1
  displayName: 'Publish results on build summary'

The output of my SonarCloudAnalyze@1 task

2020-04-23T06:35:08.7094210Z ##[section]Starting: Run SonarCloud analysis
2020-04-23T06:35:08.7102600Z ==============================================================================
2020-04-23T06:35:08.7102980Z Task         : Run Code Analysis
2020-04-23T06:35:08.7103380Z Description  : Run scanner and upload the results to the SonarCloud server.
2020-04-23T06:35:08.7103710Z Version      : 1.10.0
2020-04-23T06:35:08.7104000Z Author       : sonarsource
2020-04-23T06:35:08.7104700Z Help         : Version: 1.10.0. This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

[More Information](
2020-04-23T06:35:08.7105640Z ==============================================================================
2020-04-23T06:35:08.9253320Z [command]/Users/runner/runners/2.166.3/work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.10.0/sonar-scanner/bin/sonar-scanner
2020-04-23T06:35:09.3352770Z INFO: Scanner configuration file: /Users/runner/runners/2.166.3/work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.10.0/sonar-scanner/conf/
2020-04-23T06:35:09.3354330Z INFO: Project root configuration file: /Users/runner/runners/2.166.3/work/1/s/
2020-04-23T06:35:09.3765110Z INFO: SonarQube Scanner
2020-04-23T06:35:09.3766380Z INFO: Java 1.8.0_242 Azul Systems, Inc. (64-bit)
2020-04-23T06:35:09.3766800Z INFO: Mac OS X 10.15.4 x86_64
2020-04-23T06:35:09.7071830Z INFO: User cache: /Users/runner/.sonar/cache
2020-04-23T06:35:13.7651750Z INFO: SonarQube server 8.0.0
2020-04-23T06:35:13.7653210Z INFO: Default locale: "en_US", source code encoding: "UTF-8"
2020-04-23T06:35:14.1227250Z INFO: Load global settings
2020-04-23T06:35:15.0047250Z INFO: Load global settings (done) | time=883ms
2020-04-23T06:35:15.0098340Z INFO: Server id: XXXXX
2020-04-23T06:35:15.0156700Z INFO: User cache: /Users/runner/.sonar/cache
2020-04-23T06:35:15.0182870Z INFO: Load/download plugins
2020-04-23T06:35:15.0183470Z INFO: Load plugins index
2020-04-23T06:35:15.2426050Z INFO: Load plugins index (done) | time=224ms
2020-04-23T06:35:40.6094050Z INFO: Load/download plugins (done) | time=25591ms
2020-04-23T06:35:40.9992000Z INFO: Loaded core extensions: developer-scanner
2020-04-23T06:35:41.5144650Z INFO: Process project properties
2020-04-23T06:35:41.5213570Z INFO: Execute project builders
2020-04-23T06:35:41.5247210Z INFO: Execute project builders (done) | time=3ms
2020-04-23T06:35:41.5276590Z INFO: Project key: XXXXX.XXXXX
2020-04-23T06:35:41.5277050Z INFO: Base dir: /Users/runner/runners/2.166.3/work/1/s
2020-04-23T06:35:41.5277860Z INFO: Working dir: /Users/runner/runners/2.166.3/work/1/s/.scannerwork
2020-04-23T06:35:41.5908160Z INFO: Load project settings for component key: 'XXXXX.XXXXX'
2020-04-23T06:35:41.8254930Z INFO: Load project settings for component key: 'XXXXX.XXXXX' (done) | time=235ms
2020-04-23T06:35:41.8910770Z INFO: Found an active CI vendor: 'Azure DevOps'
2020-04-23T06:35:41.8912040Z INFO: Load project branches
2020-04-23T06:35:42.0473890Z INFO: Load project branches (done) | time=156ms
2020-04-23T06:35:42.0490940Z INFO: Check ALM binding of project 'XXXXX.XXXXX'
2020-04-23T06:35:42.2064420Z INFO: Detected project binding: NOT_BOUND
2020-04-23T06:35:42.2067160Z INFO: Check ALM binding of project 'XXXXX.XXXXX' (done) | time=155ms
2020-04-23T06:35:42.2068140Z INFO: Load project pull requests
2020-04-23T06:35:42.3593520Z INFO: Load project pull requests (done) | time=154ms
2020-04-23T06:35:42.3614330Z INFO: Load branch configuration
2020-04-23T06:35:42.3628920Z INFO: Load branch configuration (done) | time=1ms
2020-04-23T06:35:42.3960300Z INFO: Load quality profiles
2020-04-23T06:35:42.6045690Z INFO: Load quality profiles (done) | time=209ms
2020-04-23T06:35:42.6090370Z INFO: Load active rules
2020-04-23T06:35:47.1527620Z INFO: Load active rules (done) | time=4544ms
2020-04-23T06:35:47.1837420Z INFO: Organization key: XXXXX
2020-04-23T06:35:47.2290010Z INFO: Indexing files...
2020-04-23T06:35:47.2290560Z INFO: Project configuration:
2020-04-23T06:35:48.6208190Z INFO: 528 files indexed
2020-04-23T06:35:48.6209760Z INFO: 3631 files ignored because of scm ignore settings
2020-04-23T06:35:48.6210470Z INFO: Quality profile for cs: Sonar way
2020-04-23T06:35:48.6211070Z INFO: Quality profile for xml: Sonar way
2020-04-23T06:35:48.6212540Z INFO: ------------- Run sensors on module XXXXX
2020-04-23T06:35:48.7379300Z INFO: Load metrics repository
2020-04-23T06:35:48.9058080Z INFO: Load metrics repository (done) | time=164ms
2020-04-23T06:35:51.5737840Z INFO: Sensor SonarCSS Rules [cssfamily]
2020-04-23T06:35:51.5769740Z INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
2020-04-23T06:35:51.5788340Z INFO: Sensor SonarCSS Rules [cssfamily] (done) | time=2ms
2020-04-23T06:35:51.5789660Z INFO: Sensor C# Properties [csharp]
2020-04-23T06:35:51.5791470Z WARN: Property missing: 'sonar.cs.analyzer.projectOutPaths'. No protobuf files will be loaded for this project.
2020-04-23T06:35:51.5792330Z WARN: No Roslyn issues report found for this project.
2020-04-23T06:35:51.5792990Z INFO: Sensor C# Properties [csharp] (done) | time=1ms
2020-04-23T06:35:51.5793550Z INFO: Sensor JavaXmlSensor [java]
2020-04-23T06:35:51.5806770Z INFO: 8 source files to be analyzed
2020-04-23T06:35:51.5887970Z INFO: Load project repositories
2020-04-23T06:35:51.7599670Z INFO: Load project repositories (done) | time=172ms
2020-04-23T06:35:51.9521880Z INFO: Sensor JavaXmlSensor [java] (done) | time=376ms
2020-04-23T06:35:51.9522510Z INFO: 8/8 source files have been analyzed
2020-04-23T06:35:51.9523680Z INFO: Sensor HTML [web]
2020-04-23T06:35:51.9581130Z INFO: Sensor HTML [web] (done) | time=5ms
2020-04-23T06:35:51.9581780Z INFO: Sensor XML Sensor [xml]
2020-04-23T06:35:51.9597760Z INFO: 8 source files to be analyzed
2020-04-23T06:35:52.1363660Z INFO: Sensor XML Sensor [xml] (done) | time=179ms
2020-04-23T06:35:52.1365000Z INFO: Sensor JaCoCo XML Report Importer [jacoco]
2020-04-23T06:35:52.1365420Z INFO: 8/8 source files have been analyzed
2020-04-23T06:35:52.1416980Z INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
2020-04-23T06:35:52.1423590Z INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
2020-04-23T06:35:52.1424550Z INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=6ms
2020-04-23T06:35:52.1425040Z INFO: Sensor ThymeLeaf template sensor [securityjavafrontend]
2020-04-23T06:35:52.1448530Z INFO: Sensor ThymeLeaf template sensor [securityjavafrontend] (done) | time=2ms
2020-04-23T06:35:52.1449930Z INFO: Sensor C# [csharp]
2020-04-23T06:35:52.1455620Z INFO: Sensor C# [csharp] (done) | time=1ms
2020-04-23T06:35:52.1457760Z INFO: Sensor JavaSecuritySensor [security]
2020-04-23T06:35:52.1460060Z INFO: Reading type hierarchy from: /Users/runner/runners/2.166.3/work/1/s/.scannerwork/ucfg2/java
2020-04-23T06:35:52.1460830Z INFO: Read 0 type definitions
2020-04-23T06:35:52.1483410Z INFO: Reading UCFGs from: /Users/runner/runners/2.166.3/work/1/s/.scannerwork/ucfg2/java
2020-04-23T06:35:52.1506200Z INFO: No UCFGs have been included for analysis.
2020-04-23T06:35:52.1507610Z INFO: Sensor JavaSecuritySensor [security] (done) | time=3ms
2020-04-23T06:35:52.1508960Z INFO: Sensor CSharpSecuritySensor [security]
2020-04-23T06:35:52.1509680Z INFO: Reading type hierarchy from: /Users/runner/runners/2.166.3/work/1/s/ucfg_cs2
2020-04-23T06:35:52.1510370Z INFO: Read 0 type definitions
2020-04-23T06:35:52.1511080Z INFO: Reading UCFGs from: /Users/runner/runners/2.166.3/work/1/s/ucfg_cs2
2020-04-23T06:35:52.1511730Z INFO: No UCFGs have been included for analysis.
2020-04-23T06:35:52.1512370Z INFO: Sensor CSharpSecuritySensor [security] (done) | time=1ms
2020-04-23T06:35:52.1513100Z INFO: Sensor PhpSecuritySensor [security]
2020-04-23T06:35:52.1514470Z INFO: Reading type hierarchy from: /Users/runner/runners/2.166.3/work/1/s/.scannerwork/ucfg2/php
2020-04-23T06:35:52.1515200Z INFO: Read 0 type definitions
2020-04-23T06:35:52.1515870Z INFO: Reading UCFGs from: /Users/runner/runners/2.166.3/work/1/s/.scannerwork/ucfg2/php
2020-04-23T06:35:52.1516520Z INFO: No UCFGs have been included for analysis.
2020-04-23T06:35:52.1517160Z INFO: Sensor PhpSecuritySensor [security] (done) | time=0ms
2020-04-23T06:35:52.1517780Z INFO: Sensor PythonSecuritySensor [security]
2020-04-23T06:35:52.1518860Z INFO: Reading type hierarchy from: /Users/runner/runners/2.166.3/work/1/s/.scannerwork/ucfg2/python
2020-04-23T06:35:52.1519570Z INFO: Read 0 type definitions
2020-04-23T06:35:52.1520300Z INFO: Reading UCFGs from: /Users/runner/runners/2.166.3/work/1/s/.scannerwork/ucfg2/python
2020-04-23T06:35:52.1520960Z INFO: No UCFGs have been included for analysis.
2020-04-23T06:35:52.1522630Z INFO: Sensor PythonSecuritySensor [security] (done) | time=0ms
2020-04-23T06:35:52.1524100Z INFO: ------------- Run sensors on project
2020-04-23T06:35:52.1558030Z INFO: Sensor Zero Coverage Sensor
2020-04-23T06:35:52.1683290Z INFO: Sensor Zero Coverage Sensor (done) | time=13ms
2020-04-23T06:35:52.3549640Z INFO: SCM Publisher SCM provider for this project is: git
2020-04-23T06:35:52.3556440Z INFO: SCM Publisher 2 source files to be analyzed
2020-04-23T06:35:53.0838980Z INFO: SCM Publisher 0/2 source files have been analyzed (done) | time=728ms
2020-04-23T06:35:53.0840130Z WARN: Missing blame information for the following files:
2020-04-23T06:35:53.0840780Z WARN:   * XXXXX/XXXXX.Android/Resources/Resource.designer.cs
2020-04-23T06:35:53.0841500Z WARN:   * XXXXX/XXXXX.Android/Properties/AndroidManifest.xml
2020-04-23T06:35:53.0842180Z WARN: This may lead to missing/broken features in SonarCloud
2020-04-23T06:35:53.0854740Z INFO: CPD Executor Calculating CPD for 0 files
2020-04-23T06:35:53.0857630Z INFO: CPD Executor CPD calculation finished (done) | time=0ms
2020-04-23T06:35:53.3152360Z INFO: Analysis report generated in 206ms, dir size=2 MB
2020-04-23T06:35:53.6263820Z INFO: Analysis report compressed in 311ms, zip size=340 KB
2020-04-23T06:35:54.2586700Z INFO: Analysis report uploaded in 632ms
2020-04-23T06:35:54.2617320Z INFO: ANALYSIS SUCCESSFUL, you can find the results at:
2020-04-23T06:35:54.2618360Z INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
2020-04-23T06:35:54.2619830Z INFO: More about the report processing at
2020-04-23T06:35:54.3356610Z INFO: Analysis total time: 13.337 s
2020-04-23T06:35:54.3385710Z INFO: ------------------------------------------------------------------------
2020-04-23T06:35:54.3386130Z INFO: EXECUTION SUCCESS
2020-04-23T06:35:54.3386940Z INFO: ------------------------------------------------------------------------
2020-04-23T06:35:54.3387630Z INFO: Total time: 45.027s
2020-04-23T06:35:54.4658290Z INFO: Final Memory: 32M/268M
2020-04-23T06:35:54.4659950Z INFO: ------------------------------------------------------------------------
2020-04-23T06:35:54.5290820Z ##[section]Finishing: Run SonarCloud analysis

Here are some specific logs that I feel are relevant in my issue, but I could be wrong:

2020-04-23T06:35:48.6209760Z INFO: 3631 files ignored because of scm ignore settings
2020-04-23T06:35:51.5791470Z WARN: Property missing: 'sonar.cs.analyzer.projectOutPaths'. No protobuf files will be loaded for this project.

This is my first time using any kind of continuous code quality tools so I appreciate any help I can get!


Hello @xamarindev,

Your Xamarin project is built with MSBuild right? Analyzing an MSBuild project must be made with the SonarScanner for MSBuild, while here you tried to use the Scanner CLI directly. The reason is that the code analysis happens during the MSBuild process itself.

So I invite you to read our doc about the Scanner for MSBuild to understand more about how it works. Of course in an Azure pipeline, you have to use the SonarCloudPrepare and SonarCloudAnalyze tasks as you did, but select the Integrate with MSBuild option instead of Use standalone scanner.

Here is what looks like a simple Xamarin build (with one iOS and one Android build) with a SonarQube instance (it’s the same on SonarCloud, unless you use SonarCloud tasks):

  name: Azure Pipelines
  - Xamarin.iOS
  - MSBuild
  - Xamarin.Android
  - java

- task: NuGetCommand@2
  displayName: 'NuGet restore'
    restoreSolution: 'SkeletonApp/**/*.sln'

- task: SonarSource.sonarqube.15B84CA1-B62F-4A2A-A403-89B77A063157.SonarQubePrepare@4
  displayName: 'Prepare analysis on SonarQube'
    SonarQube: 'Antoine MacOS SQ 7.9.3 with Ngrok'
    projectKey: 'xamarin-test'

- task: XamariniOS@2
  displayName: 'Build Xamarin.iOS solution SkeletonApp/**/*.sln'
    solutionFile: 'SkeletonApp/**/*.sln'
    packageApp: false
    args: '/p:Platform="Any CPU"'

- task: XamarinAndroid@1
  displayName: 'Build Xamarin.Android project SkeletonApp/**/*.csproj'
    projectFile: 'SkeletonApp/**/*.csproj'

- task: SonarSource.sonarqube.6D01813A-9589-4B15-8491-8164AEB38055.SonarQubeAnalyze@4
  displayName: 'Run Code Analysis'

- task: SonarSource.sonarqube.291ed61f-1ee4-45d3-b1b0-bf822d9095ef.SonarQubePublish@4
  displayName: 'Publish Quality Gate Result'

Note that you don’t need a in this context, the Scanner for MSBuild will handle it on its own. Also none of the extra parameters you added are needed (like sonar.language, sonar.sourceEncoding, etc.), but if you need more parameter, you have an input to add them in the SonarCloudPrepare task.

I hope it will help.

Hi Antoine,

I followed your advice and was able to get the analysis working! Thanks for that - I didn’t realize we had to use MSBuild instead of CLI. I’ve also removed the file from my project.


1 Like

I have the same problem but I use Gitlab CI.Projects is ASP.NET 4.6.2 MVC with test project on .NET Core 3.1.Can you help me.