`csproj` not picked up in AzureDevOps analysis


(Prashanth Kumar) #1

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube : 7.4

  • what are you trying to achieve:
    I am trying to run sonarqube code analysis through AzureDevOps, however when i added specific visual studio (csproj) projects under exclusions it doesnt pick and it still scans.

  • what have you tried so far to achieve this
    I have added below things so far.

  1. my first job is to “prepare analysis on Sonarqube” underneath under advance options i have added
    sonar.exclusions=***.Repository.csproj, ***.bin, ..Repository.dll$ , ./.dto.dll$, ***.Test.csproj, **.entity.dll$, ***.DTO.csproj, ***.Data.csproj, Concrete/ProductRepository.cs
  2. added ***.Repository.csproj under exclusions on Sonarqube Administration-> General settings.
  3. Added the same policies in my Testsettings file as well.
  4. changed General settings from default level to see if it clears old values and picks a new one.
  5. Lastly restarted SonarQube service.

I have attached screenshot and you can see i want to exclude “repository” but it is still capturing the values, however when i tried with “test” names it perfectly excludes and shows 0.

Help will be appreciated.

Prashanth Kumar

(Amaury Levé) #2

Hi @v6prask,

Could you try with the pattern **/*DTO.csproj? The **/ part says any sub-folder from the root and *DTO.csproj any file that ends with DTO.csproj.

Let me know if you are still having issue.


(Prashanth Kumar) #3

Hello Amaury,
Greetings, I tried your option but still SonarQube scanner is capturing the count. :frowning:

Please check the screenshot.

(Prashanth Kumar) #4

(Amaury Levé) #5

Hi @v6prask,

I am sorry I gave you an incorrect answer. When you use the sonar.exclusions property the exclusion is actually applied to files/folders so obviously excluding the csproj won’t exclude the related files.

Depending on your scenario you can either update the property to specify some unique path to the files you want to exclude OR you can edit your csproj to add <SonarQubeExclude>true</SonarQubeExclude> in the PropertyGroup section to exclude everything from this project.