Sonarscanner Detects C++ code for C# codebase

Using developer edition SonarQube 9.5 (build56709) and Sonarscanner for msbuild 5.7.0.
While doing the scan on our .Net 4.7.1 code which only contains C# code am getting this error which suggests I have C/C++ code and wants me to exclude it. Being fairly new to SonarQube I tried the global exclusion as well in the administration panel but i still get this error. I also tried adding the suffixes exclusion which was suggested in the error in .sonarqube\out\ file, but that also didnt work.

Edit: Not sure if it’s relevant but I never got this error when I tried scanning with community edition of sonarqube 8.9.8.

ERROR: Error during SonarScanner execution
INFO: ------------------------------------------------------------------------

The only way to get an accurate analysis of C/C++/Objective-C files is by using the SonarSource build-wrapper and setting the property "" or by using Clang Compilation Database and setting the property "sonar.cfamily.compile-commands". None of these two options were specified.

If you don't want to analyze C/C++/Objective-C files, then prevent them from being analyzed by setting the following properties:


        at com.sonar.cpp.plugin.CFamilySensor.process(
        at com.sonar.cpp.plugin.CFamilySensor.execute(
        at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(
        at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(
        at org.sonar.scanner.scan.SpringModuleScanContainer.doAfterStart(
        at org.sonar.core.platform.SpringComponentContainer.startComponents(
        at org.sonar.core.platform.SpringComponentContainer.execute(
        at org.sonar.scanner.scan.SpringProjectScanContainer.scan(
        at org.sonar.scanner.scan.SpringProjectScanContainer.scanRecursively(
        at org.sonar.scanner.scan.SpringProjectScanContainer.doAfterStart(
        at org.sonar.core.platform.SpringComponentContainer.startComponents(
        at org.sonar.core.platform.SpringComponentContainer.execute(
        at org.sonar.scanner.bootstrap.SpringGlobalContainer.doAfterStart(
        at org.sonar.core.platform.SpringComponentContainer.startComponents(
        at org.sonar.core.platform.SpringComponentContainer.execute(
        at org.sonar.batch.bootstrapper.Batch.doExecute(
        at org.sonar.batch.bootstrapper.Batch.execute(
        at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(
        at java.base/java.lang.reflect.Method.invoke(
        at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(
        at com.sun.proxy.$Proxy0.execute(Unknown Source)
        at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(
        at org.sonarsource.scanner.api.EmbeddedScanner.execute(
        at org.sonarsource.scanner.cli.Main.execute(
        at org.sonarsource.scanner.cli.Main.execute(
        at org.sonarsource.scanner.cli.Main.main(
The SonarScanner did not complete successfully
16:28:28.778  Post-processing failed. Exit code: 1


Welcome to the community!

I’ll go backward & start by saying you didn’t see this in 8.9.8, Community Edition because Community Edition doesn’t offer C++ analysis. It simply ignored the files in question.

It’s not clear to me what you tried. A screenshot or snippet might be helpful. But did you try what the error message suggests? I.e. adding this to your analysis parameters?

What’s happening here is that analysis - which now recognizes C, C++ & Objective-C files - is seeing something it thinks should be analyzed a one of those languages. And it’s “recognizing” those files based on file suffix. The error message is suggesting you set the list of recognized file suffixes for each of these languages to -, so that no files will be identified as C, C++ or Objective-C. And that will allow your analysis to proceed.


I added the file list in the following setting:

But this doesn’t seem to help or am understanding the purpose of this wrong.

I tried to add this to .sonarqube\out\ file but it seems every time i run the scan the file gets rewritten and the settings you mentioned disappear. Now I am not sure if this is the right place to do or not. Any help in guiding me to correct file where I should put these settings would be great.



Analysis owns what’s in the .sonarqube directory (which was created by a previous analysis). I’m not surprised it gets overwritten each time. You should also have a file in your project root…? Add the properties there.

Regarding the exclusions you set, those fields are expecting patterns
that describe file paths. This is not the place for just listing file extensions.

Either you need to set your exclusions to **/*.c &etc, or you need to set the “file suffixes” inputs on Languages → C / C++ / Objective-C to .c &etc. These are not interchangeable. Or you need to set those properties in your file in the project root.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.