Build-wrapper registers file but sonar-scanner does not include in report

I created sibling folder to project folder. Added one file to folder and added file to VS2019 project (Right click on project → Add existing item). Project uses functions from file in sibling folder. build-wrapper registers file during build and adds to build-wrapper-dump.json file. sonar-scanner does not scan that file. It only scans in curent directory tree, completly ignoring build-wrapper-dump.json

I suppose this is somewhat similar to your other question Sonar-scanner ignores input file generated by build-wrapper .

It may help to think that the files being analyzed are the intersection of what the build wrapper and the scanner find. This is especially useful for projects depending on external libraries: analyzing all the source files of the dependencies has a cost, takes time, and yet wouldn’t bring much value to your application.

Nonetheless, if you desire you can extend the set of files to be considered by the scanner by using the sonar.sources property. See its documentation:

I hope this helps.

I do not see where sonar-scanner utilizes info from build-wrapper. If build wrapper registered file as compiled, why sonar-scanner does not use it?
You say:
“It may help to think that the files being analyzed are the intersection of what the build wrapper and the scanner find”
But in another issue, where build-wrapper found file and sonnar-scanner did not, you say:
“Use scanner.source” property.
You are making contradisctory statements.

I run test again. Searching for “.cpp” in build-wrapper-dump.json
C:\temp\bw-output\build-wrapper-dump.json (4 hits)
Line 63: “pch.cpp”],
Line 237: “dllmain.cpp”],
Line 404: “…\Shared\SharedSource.cpp”,
Line 405: “App.cpp”],
When I look at report, file “SharedSource.cpp” is not included although, you state “files being analyzed are the intersection of what the build wrapper and the scanner find”
build-wrapper-dump.zip (4.1 KB)
Plase take a look at attached file.
sonar-scanner log shows that build-wrapper output is used
INFO: Using build-wrapper output: C:\temp\bw-output\build-wrapper-dump.json