How to analyze C# and C++ projects in one pipeline build?

For anyone interested

Below is a correct setup for analysing projects with mix of C++ and C# in Azure pipeline.

It would be nice if this analysis setup is added to the following documentation under .NET section:

trigger: none

pool: 'Windows2022'

variables:
  buildPlatform: 'x64'
  buildConfiguration: 'Release'

steps:
- checkout: self

- task: PowerShell@2
  inputs:
    targetType: 'inline'
    script: |
      Invoke-WebRequest -Uri 'https://sq.corp.cloud.net/static/cpp/build-wrapper-win-x86.zip' -OutFile 'build-wrapper.zip'
.      Expand-Archive -Path 'build-wrapper.zip' -DestinationPath '.' -Force
 
- task: SonarQubePrepare@5
  inputs:
    SonarQube: 'https://sq.corp.cloud.net'
    scannerMode: 'MSBuild'
    projectKey: 'xxxxx'
    extraProperties: |
      sonar.cfamily.build-wrapper-output=$(Build.SourcesDirectory)\bw_output
      sonar.verbose=true

- task: CmdLine@2
  inputs:
    script: |
      build-wrapper-win-x86\build-wrapper-win-x86-64.exe --out-dir $(Build.SourcesDirectory)\bw_output "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\MSBuild.exe" CEMConnectionWizardWin\CEMConnectionWizardWin.sln -t:Rebuild /p:configuration=release /p:platform=x64
      
- task: SonarQubeAnalyze@5

- task: SonarQubePublish@5
  inputs:
    pollingTimeoutSec: '300'

- task: sonar-buildbreaker@8
  inputs:
    SonarQube: 'https://sq.corp.cloud.net'
1 Like