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

Hi Sonar Team,

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension):
    SonarQube v9.9.2 (build 77730) - Developer Edition
    BuildWrapper v6.41.1 (for C++ analysis)
    dotnet-sonarscanner v6.0.0

  • how is SonarQube deployed: zip, Docker, Helm :

  • what are you trying to achieve :
    A C++ / C# analysis

  • what have you tried so far to achieve this :

The project is mainly composed of C++ and C# code.
We first have some CMake code that generates all of our project files and solution file. Then we have a .NET Core build that builds the project from the solution file previously generated.

The whole process is made in a Jenkins pipeline, running in a windows 10 containers on a windows 10 host.

From what I understood from the documentation, we implemented the sonar scanners as follow :

1 – As we have some C++, we downloaded the build-wrapper tool to encapsulate our build command.

2 – As we also want C# analysis, we used the .NET Core sonarscanner.

This looks like this:

Step 1 : download build wrapper from our sonar server : http://<our_sonar_url>/static/cpp/build-wrapper-win-x86.zip

Step 2 : generate project and solution files with our CMake script

Step 3 : use of sonarscanner begin command : dotnet sonarscanner begin /k:<project_key> -d:sonar.login=<login_token> -d:sonar.host.url=<sonar_url> -d:sonar.cfamily.build-wrapper-output=bw-output"

Step 4 : build the solution with the wrapper : build-wrapper-win-x86-64.exe --out-dir bw-output <our_build_command>

Step 5 : use of sonarscanner end command : dotnet sonarscanner end -d:sonar.login=<login_token>

We do not use sonar-project.properties, nor did we setup the SonarQube.Analysis.xml as information are given in the sonarscanner begin command.

As a result, the solution builds correctly (at least we found nothing strange in build logs) but when the end command runs, we can see these line of log:

java.lang.IllegalStateException: The “build-wrapper-dump.json” file was found but 0 C/C++/Objective-C files were analyzed. Please make sure that:

  • you are using the latest version of the build-wrapper and the CFamily analyzer
  • you are correctly invoking the scanner with correct configuration
  • your compiler is supported
  • you are wrapping your build correctly
  • you are wrapping a full/clean build
  • you are providing the path to the correct build-wrapper output directory
  • you are building and analyzing the same source checkout, absolute paths must be identical in build and analysis steps

I struggle to find to blocking point here. Can someone help?

Hey there.

It sounds like you have the process right. Can you zip up your build-wrapper output directory and share it?


Thank you for coming back to me.

I can’t share publicly logs of our project, so i set up a very minimalist one with same structure, and could reproduce the output.

Here are the logs:
bw-output.zip (9.2 KB)

Also, there is a second point to adress (for later).
We have our code in “code” folder, and usually build our proj files and sln file in a different “build” folder.
That’s a problem for sonarscanner as it can’t find any cpp files in the “build” folder.
In order to solve problems sequentially, i’ve put everything in the same folder, in this case “code”, but i’d like to discuss this point in the end also.

Can you share the sonar-scanner output as well from this reproducer, preferably with DEBUG level logging (sonar-scanner -X)?

With that I should be able to pass it along to the right team, who is probably better equipped to answer your second question as well.

Here are the dotnet-sonarscanner log in debug mode, as asked:
Sonar_log.zip (10.9 KB)

Thank you very much for your help.

Hey there.

Something tells me that this is what’s wrong.

16:33:22.712 DEBUG: Declared extensions of language C++ were converted to sonar.lang.patterns.cpp : **/*.-

Have you configured sonar.cpp.file.suffixes somewhere? It can hide in the server/project settings as well in the SonarQube UI (Administration > General Settings > Languages > C/C++/Objective-C) . You can also override these as an analysis parameter (/d:sonar.cpp.file.suffixes= .cc,.cpp,.cxx,.c++,.hh,.hpp,.hxx,.h++,.ipp)

Indeed, on the UI C++ file suffixes were set to “-”.

I’ve changed it to what you said, i now have that in my log :

16:51:26.763 DEBUG: Declared extensions of language C were converted to sonar.lang.patterns.c : **/*.c,**/*.h
16:51:26.763 DEBUG: Declared extensions of language C++ were converted to sonar.lang.patterns.cpp : **/*.cc,.cpp,.cxx,.c++,.hh,.hpp,.hxx,.h++,.ipp  
16:51:26.763 DEBUG: Declared extensions of language Objective-C were converted to sonar.lang.patterns.objc : **/*.m

But sadly the result is the same in the end :frowning:

EDIT : i went too fast edition option, let me do that again i see an error in my setting

EDIT2: Ok so after fixing parameters in sonar admin UI, i first got this message:
Language of file 'code\planning\imagemanagement\main\planning\src\main.cpp' can not be decided as the file matches patterns of both sonar.lang.patterns.cxx : **/*.cc,**/*.cpp,**/*.cxx,**/*.c++,**/*.hh,**/*.hxx,**/*.h++,**/*.ipp and sonar.lang.patterns.cpp : **/*.cc,**/*.cpp,**/*.cxx,**/*.c++,**/*.hh,**/*.hpp,**/*.hxx,**/*.h++,**/*.ipp

So i re-run the dotnet-sonarscanner begin with the option /d:sonar.lang.patterns.cxx="-" and i got a successful analysis on the minimalist project.

I’m trying on the fullscale project