I am using SonarQube server Enterprise Edition v2026.1 (119033), deployed using a zip on Ubuntu 24.04.
I want to combine the analysis of C# code and C\C++ code. Initially, we used to have C++ analysis on a separate SQ project using the SonarScanner CLI with the buildWrapper, which covered all the required files, and the LOC was 177K.
To combine C++ with C#, I am using the MSBuild SonarScanner also with the buildwrapper for the C++ code, which shows fewer LOC(165K), and some important code files were skipped for some reason.
Sonar parameters I used with SonarScanner CLI version 7.0.2.4839:
“-Dsonar.projectKey=${getProjectName()}_cpp”,
“-Dsonar.sourceEncoding=UTF-8”,
“-Dsonar.buildString=${env.BUILD_NUMBER}”,
“-Dsonar.scm.provider=git”,
“-Dsonar.scm.revision=${BuildVariables.GIT_COMMIT_HASH}”,
“-Dsonar.projectBaseDir=${env.WORKSPACE}/${ArtifactsIn}”,
“-Dsonar.verbose=true”,
“-Dsonar.inclusions=**/*.cpp,**/*.h",
"-Dsonar.exclusions=**/coverage/**,**/UnitTests/**,**/.ci/**,**/BuildAgents/**,**/*.cs,**/*.html,**/*.Html”,
“-Dsonar.cfamily.compilecommands=${env.WORKSPACE}/${BuildWrapperOutputDirectory}/compile_commands.json”,
“-Dsonar.cfamily.cobertura.reportPaths=${cppCoveragePaths}”
Parameters I used with MSBUILD sonarscanner version 10.1.0.110937:
“/v:${BuildVariables.VERSION}”,“/k:${getProjectName()}”,“/n:${getProjectName()",
“/d:sonar.buildString=${env.BUILD_NUMBER}”,
‘/d:sonar.verbose=true’,
“/d:sonar.cs.vscoveragexml.reportsPaths=${codeCoverageResultsFilePath}”,
‘/d:sonar.sourceEncoding=UTF8’,
“/d:sonar.projectBaseDir=${env.WORKSPACE}/${ArtifactsIn}”,
“/d:sonar.exclusions=**/UnitTests/**,**/.ci/**,**/*.html”,
"/d:sonar.cfamily.compilecommands=${env.WORKSPACE}/${BuildWrapperOutputDirectory}/compile_commands.json”,
“/d:sonar.cfamily.cobertura.reportPaths=${cppCoveragePaths}”,
I also tried to use compile_commands with variants by compiling each platform, and used the following parameters, but got the same result:
SonarScanner.MSBuild.exe begin
& $Arguments.BuildWrapperExecutablePath --out-dir "$($buildWrapperOutputDirectory)\x86" $msbuildPath $projectPath /P:Configuration=Release /P:Platform="x86" /t:Rebuild /nodeReuse:False /m
& $Arguments.BuildWrapperExecutablePath --out-dir "$($buildWrapperOutputDirectory)\x64" $msbuildPath $projectPath /P:Configuration=Release /P:Platform="x64" /t:Rebuild /nodeReuse:False /m
SonarScanner.MSBuild.exe end
'/d:sonar.cfamily.variants.names=x86,x64',
"/d:sonar.cfamily.variants.dir=${env.WORKSPACE}/${ArtifactsIn}/${BuildWrapperOutputDirectory}"
My Question is, do different scanners have different results? And how can I get a complete analysis for my C++ code when I combine it with C#?