Hey @Huzaifa, is the code in this folder being analyzed as main code or as test code? I’m asking because sonar.exclusions is the property to be used to exclude main code, but for code that is detected and analyzed as test code you need sonar.test.exclusions (see docs). By the way, these properties can also be set in the UI.
Could you share debug-level scanner logs? Typically the logs contain the exclusions being applied and they also show which code is indexed as main and which one as test.
C:\Letest Speco code>dotnet “C:\Letest Speco code\speco_secureguardcms/Sonar Scanner/SonarScanner.MSBuild.dll” begin /k:“Safety_Surveillance” /d:sonar.token=“squ_72950cd7b58f576v931e2bd75aeedc78d465ee59” /d:sonar.verbose=true
SonarScanner for MSBuild 6.0
Using the .NET Core version of the Scanner for MSBuild
Default properties file was found at C:\Letest Speco code\speco_secureguardcms\Sonar Scanner\SonarQube.Analysis.xml
Loading analysis properties from C:\Letest Speco code\speco_secureguardcms\Sonar Scanner\SonarQube.Analysis.xml
sonar.verbose=true was specified - setting the log verbosity to ‘Debug’
Pre-processing started.
Preparing working directories…
Using environment variables to determine the download directory…
10:27:01.703 10:27:01.676 Loading analysis properties from C:\Letest Speco code\speco_secureguardcms\Sonar Scanner\SonarQube.Analysis.xml
10:27:01.704 10:27:01.703 sonar.verbose=true was specified - setting the log verbosity to ‘Debug’
10:27:01.717 Updating build integration targets…
10:27:01.728 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\1734576\AppData\Local\Microsoft\MSBuild\4.0\Microsoft.Common.targets\ImportBefore
10:27:01.73 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\1734576\AppData\Local\Microsoft\MSBuild\10.0\Microsoft.Common.targets\ImportBefore
10:27:01.733 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\1734576\AppData\Local\Microsoft\MSBuild\11.0\Microsoft.Common.targets\ImportBefore
10:27:01.736 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\1734576\AppData\Local\Microsoft\MSBuild\12.0\Microsoft.Common.targets\ImportBefore
10:27:01.739 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\1734576\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.targets\ImportBefore
10:27:01.742 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\1734576\AppData\Local\Microsoft\MSBuild\15.0\Microsoft.Common.targets\ImportBefore
10:27:01.744 The file SonarQube.Integration.ImportBefore.targets is up to date at C:\Users\1734576\AppData\Local\Microsoft\MSBuild\Current\Microsoft.Common.targets\ImportBefore
10:27:01.753 Installed SonarQube.Integration.targets to C:\Letest Speco code.sonarqube\bin\targets
10:27:01.754 Creating config and output folders…
10:27:01.755 Creating directory: C:\Letest Speco code.sonarqube\conf
10:27:01.756 Creating directory: C:\Letest Speco code.sonarqube\out
10:27:01.809 Fetching server version…
10:27:01.811 Downloading from http://sonarqube.einfochips.com:8080/api/server/version…
10:27:02.071 Response received from http://sonarqube.einfochips.com:8080/api/server/version…
10:27:02.074 Checking if the server version is supported…
10:27:02.109 Checking validity of server license…
10:27:02.11 Downloading from http://sonarqube.einfochips.com:8080/api/editions/is_valid_license…
10:27:02.151 Response received from http://sonarqube.einfochips.com:8080/api/editions/is_valid_license…
10:27:02.167 SonarQube Community Edition detected, license is valid.
10:27:02.174 Fetching analysis configuration settings…
10:27:02.176 Fetching properties for project ‘Safety_Surveillance’…
10:27:02.177 Downloading from http://sonarqube.einfochips.com:8080/api/settings/values?component=Safety_Surveillance…
10:27:02.241 Response received from http://sonarqube.einfochips.com:8080/api/settings/values?component=Safety_Surveillance…
10:27:02.269 Downloading from http://sonarqube.einfochips.com:8080/api/languages/list…
10:27:02.291 Response received from http://sonarqube.einfochips.com:8080/api/languages/list…
10:27:02.294 Fetching quality profile for project ‘Safety_Surveillance’…
10:27:02.295 Downloading from http://sonarqube.einfochips.com:8080/api/qualityprofiles/search?project=Safety_Surveillance…
10:27:02.359 Response received from http://sonarqube.einfochips.com:8080/api/qualityprofiles/search?project=Safety_Surveillance…
10:27:02.365 Fetching rules for quality profile 'AX_T562K0HxXzRwihZfHwQZ&p=1…
10:27:02.366 Downloading from http://sonarqube.einfochips.com:8080/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=AX_T56K02HxXRwhZqfHwQZ&p=1…
10:27:02.741 Response received from http://sonarqube.einfochips.com:8080/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=AX_T562K0HxXzRwhZfHwQZ&p=1…
10:27:02.781 Local analyzer cache: C:\Users\1734576\AppData\Local\Temp.sonarqube\resources
10:27:02.785 Writing Roslyn generated ruleset to C:\Letest Speco code.sonarqube\conf\Sonar-cs.ruleset…
10:27:02.796 Writing Roslyn generated ruleset to C:\Letest Speco code.sonarqube\conf\Sonar-cs-none.ruleset…
10:27:02.8 Provisioning analyzer assemblies for cs…
10:27:02.801 Installing required Roslyn analyzers…
10:27:02.801 Processing plugin: csharp version 10.33.0.1635
10:27:02.867 Cache hit: using plugin files from C:\Users\1734576\AppData\Local\Temp.sonarqube\resources\2
10:27:02.868 Processing plugin: vbnet version 10.33.0.1635
10:27:02.872 Cache hit: using plugin files from C:\Users\1734576\AppData\Local\Temp.sonarqube\resources\3
10:27:02.877 Writing Roslyn analyzer additional file to C:\Letest Speco code.sonarqube\conf\cs\SonarLint.xml…
10:27:02.881 Fetching quality profile for project ‘Safety_Surveillance’…
10:27:02.882 Downloading from http://sonarqube.einfochips.com:8080/api/qualityprofiles/search?project=Safety_Surveillance…
10:27:02.929 Response received from http://sonarqube.einfochips.com:8080/api/qualityprofiles/search?project=Safety_Surveillance…
10:27:02.93 Fetching rules for quality profile ‘AX_T9K1qHxXRwhZfHxja’…
10:27:02.93 Downloading from http://sonarqube.einfochips.com:8080/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=AX_T56K02HxXRwhZqfHwQZ&p=1…
10:27:03.118 Response received from http://sonarqube.einfochips.com:8080/api/rules/search?f=repo,name,severity,lang,internalKey,templateKey,params,actives&ps=500&qprofile=AX_T562K0HxXzRwhZfHwQZ&p=1…
10:27:03.129 Local analyzer cache: C:\Users\1734576\AppData\Local\Temp.sonarqube\resources
10:27:03.131 Writing Roslyn generated ruleset to C:\Letest Speco code.sonarqube\conf\Sonar-vbnet.ruleset…
10:27:03.168 Writing Roslyn generated ruleset to C:\Letest Speco code.sonarqube\conf\Sonar-vbnet-none.ruleset…
10:27:03.173 Provisioning analyzer assemblies for vbnet…
10:27:03.175 Installing required Roslyn analyzers…
10:27:03.176 Processing plugin: csharp version 12.33.7.1635
10:27:03.18 Cache hit: using plugin files from C:\Users\1734576\AppData\Local\Temp.sonarqube\resources\2
10:27:03.18 Processing plugin: vbnet version 12.33.7.1635
10:27:03.186 Cache hit: using plugin files from C:\Users\1734576\AppData\Local\Temp.sonarqube\resources\3
10:27:03.188 Writing Roslyn analyzer additional file to C:\Letest Speco code.sonarqube\conf\vbnet\SonarLint.xml…
10:27:03.246 Processing analysis cache
10:27:03.248 Incremental PR analysis: Base branch parameter was not provided.
10:27:03.248 Cache data is empty. A full analysis will be performed.
10:27:03.266 Pre-processing succeeded.
Hey @Huzaifa, from your logs, the MSBuild scanner is loading its analysis properties from C:\Letest Speco code\speco_secureguardcms\Sonar Scanner\SonarQube.Analysis.xml, not from the C:\Letest Speco code properties file you mentioned. With SonarScanner for .NET / MSBuild, sonar-project.properties (or other standalone properties files) in the workspace are not used.
The correct way to set custom properties in a .NET analysis is:
Inline it in the command: pass /d:sonar.exclusions="**/SGClient.Infrastructure/Native/**/*" to the dotnet begin command.
Set it in the SonarQube UI: Project Settings > General Settings > Analysis Scope > Source File Exclusions.