How to scan the solution with both C# and C++. Many projects are missing from summary


I’m trying to scan a solution with a mix of projects in c++ and c#. For that, I’m using the following tasks in my pipeline:

- task: PowerShell@2
  displayName: Get the latest version of the SonarCloud BuildWrapper for C++
  condition: and(succeeded(),eq(variables['executeSonarAnalisys'],'yes'))
  continueOnError: true
    targetType: 'inline'
    script: |
      Invoke-WebRequest -Uri '' -OutFile ''
      Expand-Archive -Path '' -DestinationPath '$(Agent.BuildDirectory)\'
    showWarnings: true

- task: SonarCloudPrepare@1
  displayName: Sonar Cloud Prepare
  condition: and(succeeded(),eq(variables['executeSonarAnalisys'],'yes'))
    SonarCloud: 'blblablabla'
    organization: 'bleblebleble'
    scannerMode: 'MSBuild'
    configMode: 'manual'
    cliProjectKey: 'myprojectkey'
    cliProjectName: 'ProjectName'
    cliProjectVersion: ''  
    projectKey: 'myprojectkey'
    projectName: 'ProjectName'
    projectVersion: ''
    extraProperties: |
      # Additional properties that will be passed to the scanner, 
      # Put one key=value per line, example:
      sonar.exclusions=pipelines/**, 3rdPartyLibs/**, build/**, Backup/**, Debug/**, **/bin/**, **/x86/**, **/x64/**, **/debug/**, **/release/**, Web/**$(Agent.BuildDirectory)

- task: CmdLine@2
  condition: and(succeeded(),eq(variables['executeSonarAnalisys'],'yes'))
    script: |
      "$(Agent.BuildDirectory)\build-wrapper-win-x86\build-wrapper-win-x86-64.exe" --out-dir $(Agent.BuildDirectory) "%msbuildpath%" "DigitalTV_Projects_v2.sln" /p:Configuration=$(buildConfiguration) /p:Platform=$(buildPlatform)
      dir $(Agent.BuildDirectory)\

- task: SonarCloudAnalyze@1
  condition: and(succeeded(),eq(variables['executeSonarAnalisys'],'yes'))
  continueOnError: true

- task: SonarCloudPublish@1
  condition: and(succeeded(),eq(variables['executeSonarAnalisys'],'yes'))
  continueOnError: true
    pollingTimeoutSec: '300'

The pipeline executes correctly and the solution is built OK and completely, but in the final summary MANY c# projects are missing (but not all!!!).

The finishing log of the analyze part:

12:15:49.623 INFO: CPD Executor CPD calculation finished (done) | time=344ms
12:15:51.994 DEBUG: Could not detect the dotnet / msbuild version
12:15:52.604 INFO: Analysis report generated in 2918ms, dir size=24 MB
12:15:54.570 INFO: Analysis report compressed in 1966ms, zip size=7 MB
12:15:54.570 INFO: Analysis report generated in D:\a\1\.sonarqube\out\.sonar\scanner-report
12:15:54.570 DEBUG: Upload report
12:15:55.422 DEBUG: POST 200ñabñabña&projectKey=bñabñebñebñe&projectName=lolollo | time=852ms
12:15:55.425 INFO: Analysis report uploaded in 855ms
12:15:55.425 DEBUG: Report metadata written to D:\a\_temp\sonar\20220831.7\0afbeee0-7681-e173-926a-c1ba4d01aa09\report-task.txt
12:15:55.425 INFO: ANALYSIS SUCCESSFUL, you can find the results at:
12:15:55.425 INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
12:15:55.425 INFO: More about the report processing at
12:15:55.425 DEBUG: Post-jobs : 
12:15:55.425 INFO: Closing heartbeat service
12:15:55.534 INFO: Analysis total time: 11:48.341 s
12:15:55.534 INFO: ------------------------------------------------------------------------
12:15:55.534 INFO: ------------------------------------------------------------------------
12:15:55.534 INFO: Total time: 12:02.104s
12:15:55.784 INFO: Final Memory: 43M/144M
12:15:55.784 INFO: ------------------------------------------------------------------------
Process returned exit code 0
The SonarScanner CLI has finished
12:15:56.41  Post-processing succeeded.

If I execute the pipeline using the PrepareTask with scannerMode: MSBuild, then all c# projects appear, but obviously then all the c++ projects are missing.

Any ideas on how to get results for both c++ and c# projects together please?

Thank you!

Hi Jordi,

You’ll need to use both the build-wrapper and the begin/end tasks, as described in the docs.


Thank you for your answer Ann!

I thought that the “begin” and “end” tasks were handled automatically in the devops pipeline by the SonarCloudPrepare@1 and the SonarCloudAnalyze@1 pipeline tasks?

Otherwise, I guess that I would have to download the SonarScanner.MSBuild.exe as a pretask and then run the begin and end steps myself. And then… completely omit the SonarCloudPrepare@1 task? Its worth a try!

But according to the documentation Azure DevOps Integration | SonarQube Docs the begin and end steps should be handled automatically…

Azure DevOps Server - build agents
If you are using Microsoft-hosted build agents then there is nothing else to install. The extension will work with all of the hosted agents (Windows, Linux, and macOS).

What am I missing? :slight_smile:

just to make it clear, when I go to the “code” tab in the “main branch”, I can see some projects there (some are c++ and some are c#), but the majority of the projects are simply missing.

There are 15 projects shown out of 30+


Would you care to share your entire job log?


Sure no problem, the analyze step is like 30k lines long… I’ll try to attach a file.

Prepare step:
SonarCloudLogPrepare_20220831.txt (10.5 KB)

Analyze step:
SonarCloudLog_20220831.txt (5.6 MB)

Thank you!


Thanks for the logs. They’re… a lot. :joy:

You’re right, it seems that the prepare step is covering the begin step:

2022-08-31T11:59:45.8017452Z [command]D:\a\_tasks\SonarCloudPrepare_14d9cde6-c1da-4d55-aa01-2965cd301255\1.29.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe begin /k:km-ad-spa-atriacapture /o:kantar-media

When I look at the second log, It seems to be processing 24 modules. Can you characterize what’s missing? I don’t see anything out of the ordinary in the second log, but that’s quite possibly a forest-for-the-trees proposition.