Sonar scanner not scanning multiple solutions

SonarCloud : - 9.0
Scanner: 5.13 OR 5.0.3
CI/CD :- Jenkins
Language:- .NET
Build:- MSBuild.exe(version 14 for scanner and 4 for building
).

We are trying to achieve code coverage for our .NET projects. The project base directory contains multiple sln(solutions) under the root folder and also we have created separate unit test case solution under the same root folder.
While building the solutions on Jenkins pipeline call targets we are building all solutions in build pipeline but when we are seeing the code coverage it is only showing the first solution code coverage from that build pipeline

For ex:-
Build:-
Solution1:- ABC.sln
Solution2:- BCD.sln
Solution3:- CDC.sln
We are able to see the unit test case code coverage for ABC.sln on sonar dashboard but the rest of the solutions are not showing any code coverage.
Additionally from CDC.sln and BCD.sln we are seeing (n) lines to cover for newly added code on sonar dashboard.

In Sonar.Sources we can see the lots of files are including but in Sonar.Tests we are not seeing any unit test case files as we haven’t manually configured Sonar.Sources And Sonar.Tests in scanner starting part.

We are able to generate the open cover and unit test case result xml’s and will attach FYR.
We are seeing some issue with sonar end logs.
09:21:23.611 DEBUG: Skipping the file (ID ‘1998’, path ‘Utils\GlobalResources\Resource.Designer.cs’, NO INDEXED PATH), line ‘56’, visitCount ‘0’ because file is not indexed or does not have the supported language.

09:21:16.488 DEBUG: Analyzing coverage with wildcardPatternFileProvider with base dir ‘C:\Build\Products\Branch1.’ and file separator ''.

Did not find deterministic source path in ‘\UnitTests\Tests\Abc.cs’. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.

Our unit test cases are passing while building the project.


r

Code coverage is showing for DataAccess.sln


Sonar (2).zip (1.9 MB)

Hi,

Please provide your full, debug analysis logs:

Share the Scanner for .NET verbose logs

  • Add /d:"sonar.verbose=true" to the…
    • SonarScanner.MSBuild.exe or dotnet sonarscanner begin command to get more detailed logs
      • For example: SonarScanner.MSBuild.exe begin /k:"MyProject" /d:"sonar.verbose=true"
    • “SonarQubePrepare” or “SonarCloudPrepare” task’s extraProperties argument if you are using Azure DevOps
      • For example:
        - task: SonarCloudPrepare@1
            inputs:
              SonarCloud: 'sonarcloud'
              organization: 'foo'
              scannerMode: 'MSBuild'
              projectKey: 'foo_sonar-scanning-someconsoleapp'
              projectName: 'sonar-scanning-someconsoleapp'
              extraProperties: |
                sonar.verbose=true
        
  • The important logs are in the END step (i.e. SonarQubeAnalyze / SonarCloudAnalyze / “Run Code Analysis”)

Share the msbuild detailed logs

MsBuild.exe /t:Rebuild /v:d

or

dotnet build -v:d

 
Thx,
Ann

Hi Team,
Hope you are doing well!!.

Please find the full logs attched including sonar scanner start , end and MSBuild.exe for running build targets

Full Log.zip (2.9 MB)

Hi,

Thanks for the log.

In it, I see a number of variations of this:

  09:21:16.491 DEBUG: Did not find deterministic source path in 'F:\Build\Products\MyBranch\Tests\UnitTests\UnitTests\Tests\GuidGeneratorUnitTests.cs'. Will skip this coverage entry. Verify sonar.sources in .sonarqube\out\sonar-project.properties.
  09:21:16.491 DEBUG: CoveredFile created: (ID '1', path 'F:\Build\Products\MyBranch\Tests\UnitTests\UnitTests\Tests\GuidGeneratorUnitTests.cs', NO INDEXED PATH).

It seems that the paths in the coverage report don’t match the paths analysis is seeing.

 
HTH,
Ann

Hi,
Greeting for the day.
Thanks for the reply.

We are referencing sonar output file in the same location I am wondering why it is not considering the file path.

I am attaching sonar-project.properites details FYI

Scanner details.txt (1.5 KB)
sonar-project.zip (80.3 KB)

Hi,

I’m not sure what you expect from the files you sent. You need to look into why / how the paths the scanner is seeing in the coverage report don’t match the ones it’s seeing during analysis.

Regarding your ‘Scanner details.txt’ file, I don’t understand why run_opencover appears after sonarqube_end. If you want OpenCover results taken into account in the analysis, it’ll need to run before analysis ends.

 
HTH,
Ann