SonarQube.Analysis.xml being ignored

Current software:
Scanner sonarscanner-msbuild-netcoreapp30
Sonarqube Version 6.7.6 (build 38781)

I’m new to Sonarqube. I’ve just started to run sonarscanner on a .Net Core C# application. The scan runs ok and the analysis is being shown on our corporate sonarqube site.

The solution has a UI project which contains javascript. I want to exclude those javascript files from the analysis

I’ve not been able to get that exclusion to work.

Can anyone suggest what I’m doing wrong?

I’ve added an exclusion to the begin statement (below) and since that didn’t work, also added SonarQube.Analysis.xml to the root of the folder structure (below).

Infrastructure-wise it’s running on jenkins, on a windows jenkins node with sonar scannere installed via chocolatey. Having said that, I have the same issue when running the scan on my local PC with the commands typed directly into powershell…

begin statement

dotnet "PathToSonarscanner\sonarscanner.msbuild.dll" begin /k:"projectkeygoeshere" /d:sonar.verbose=true /"urlgoeshere" /d:sonar.login="loginkeygoeshere"  /d:sonar.coverage.exclusions="**/*.js"


<?xml version="1.0" encoding="utf-8" ?>
  <Property Name="sonar.verbose">true</Property>
  <Property Name="">urlgoeshere</Property>
  <Property Name="sonar.login">loginkeygoeshere</Property>
  <Property Name="sonar.projectKey">projectkeygoeshere</Property>
  <Property Name="sonar.sources">.</Property>
  <Property Name="sonar.coverage.exclusions">**/*.js</Property>

Hi @aspidistro - welcome to the community!

sonar.coverage.exclusions stops files from being included in the calculation of code coverage.

sonar.exclusions stops files from being analysed, which sounds like what you are looking for.

Try passing the settings file as a parameter to the scanner:

dotnet sonarscanner begin /k:"PROJECT_KEY" /s:"SETTINGS_FILE_ABSOLUTE_PATH"

When I was working on this a month or two ago I run into an issue, where the dotnet scanner was not be able to find the settings file using relative paths no matter where I’ve placed it, so do try to use the full, absolute path.

ps.: I’ve also noticed the scanner only read certain properties from the file, notably the ones that have a /d: parameter prefix when used as params, so eg. the project name, the project key and the project version did only work for me as command parameters (/n:, /k: and /v:) directly passed to the scanner on execution.

1 Like