C# Solution Sonar build fails after adding C++ project

Hi everyone,

We have a solution with C# projects building in Azure DevOps SonarCloud pipeline. However, after adding a C++ project to our solution our Sonar pipeline build now fails.
I`ve searched solution for this issue. To fix this was added build wrapper to our build:

Dowloading and installing build wrapper:

$path = "$(Agent.BuildDirectory)\build-wrapper-win-x86-64"
If(!(test-path -PathType container $path))
      New-Item -ItemType Directory -Path $path

Invoke-Webrequest -URI https://next.sonarqube.com/sonarqube/static/cpp/build-wrapper-win-x86.zip -OutFile $(Agent.BuildDirectory)\build-wrapper-win-x86-64\build-wrapper-win-x86.zip

Add-Type -AssemblyName System.IO.Compression.FileSystem
function Unzip
    param([string]$zipfile, [string]$outpath)

    [System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)

Unzip "$(Agent.BuildDirectory)\build-wrapper-win-x86-64\build-wrapper-win-x86.zip" "$(Agent.BuildDirectory)\"

Also added building in build-wrapper:

$path = &"${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" -latest -prerelease -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe

$(Agent.BuildDirectory)\build-wrapper-win-x86\build-wrapper-win-x86-64.exe --out-dir $(Agent.BuildDirectory) $path /t:Rebuild

As a result we have errors in Run Code Analysis step:

The "build-wrapper-dump.json" file was found but 0 C/C++/Objective-C files were analyzed.


##[error]The SonarScanner did not complete successfully


Welcome to the community!

Per the docs can you try adding the nodeReuse:False command-line option?


Hi Ann, thanks for idea
But adding nodeReuse:False didn`t work(

The issue remains the same


1 Like

Hi @a.synytsia and welcome to the community.
Could you please share the build-wrapper.log file that was generated while running the build-wrapper?

Hi Fred_Tingaud
Im in progress to get that build-wrapper.log file. As it is in all in Azure DevOps. Im trying to figure out fow to get it from there.
Ill update as soon as Ill get it.

Thanks, Anton

Hi all, sorry for long answer
Ive tested my implementation C# with C++ code and its woking if I exclude cpp files in Prepare Analysis Step using line (sonar.cpp.file.suffixes=true)

I know that its not correct but I just want to test scann with build-wrapper of old code without cpp files And its working.

The only difference is that in successful scan it has 0 cpp files to scann and in failed scann we have attempt to scann 5 cpp files (screenshots


So my question is:
Do sonar scan have some restrictions on scanning cpp files ?

Hi @a.synytsia ,
There is no restriction on scanning cpp files in SonarCloud.
The build-wrapper.log file would be more convenient for us to look into what is going wrong with your C++ files.