How to include folders projects for sonar analysis which are not part of solution using sonar scanner for .net

1k Views Asked by At

How do I configure the sonar to include folders or projects which are not part of the current .net solution. I have the following structure my current project:

MyProject - Root Folder ProjectA - Normal .net project ProjectB MyProject.Services MyProject.Services - This is a asp.net core project MyProject.Services.sln MyProject.Services.Model MyProject.Services.Repository MyProject.sln

folder_structure

MyProject.Services is a separate solution having .net core project. During the sonar analysis - it is only analyzing the files associated with MyProject.sln. The requirement is to include files from MyProject.Services as well to have a single report for both solutions.

I tried to include it as a parameter (sonar.sources) but got below error: File "..." can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files

We are using a powershell script for the sonar begin/end step which is getting executed through bamboo build job.

Sonar Scanner: C:\sonar-scanner-msbuild-4.6.0.1930-net46\SonarScanner.MSBuild.exe Sonarqube version: 8.9

1

There are 1 best solutions below

0
On

The Sonar C# and Sonar VB.NET analyzers are Roslyn analyzers, so you need to build a project/solution to get the analysis results. So, if you want issues for MyProject.Services you will have to build it.

You can include the results for multiple MSBuild projects/solutions in the same Sonar project - just build the required projects between the Scanner begin and end steps e.g.

  • run the scanner begin step
  • build MyProject.Services.sln
  • build MyProject.sln
  • run the scanner end step