I am using version of SonarQube version 7.2 along with sonarscanner msbuild. I am trying to analyze a C# solution and exclude analysis of all code in the ClassLibrary3 folder. My solution directory is like the following:
src/CSharpConsole
CSharpConsole contains the CSharpConsole.sln file along with the folders ClassLibrary3 and ClassLibrary2.
I had no problems when putting the following in a project file to exclude it but we don’t want to go that route:
true.
I tried all different combinations to exclude the folder in the UI (in Global Source File Exclusions along with Source File Exclusions but none seem to work. I have tried ClassLibrary3//*, ClassLibrary3, /ClassLibrary3, along with CSharpConsole/ClassLibrary3//*. I also tried /d:sonar.exclusions=“ClassLibrary3” in the command line but that didn’t work either. Below are my commands and the results:
C:\Users\mstack\source\repos\CSharpConsole>SonarScanner.MSBuild.exe begin /k:"project9000" /d:sonar.excusion.exclusions=
"ClassLibrary3"
SonarScanner for MSBuild 4.3.1
Using the .NET Framework version of the Scanner for MSBuild
Default properties file was found at C:\sonar-scanner-msbuild-4.3.1.1372\SonarQube.Analysis.xml
Loading analysis properties from C:\sonar-scanner-msbuild-4.3.1.1372\SonarQube.Analysis.xml
Pre-processing started.
Preparing working directories...
10:27:18.138 Updating build integration targets...
10:27:18.177 Fetching analysis configuration settings...
10:27:18.551 Provisioning analyzer assemblies for cs...
10:27:18.553 Installing required Roslyn analyzers...
10:27:18.705 Pre-processing succeeded.
C:\Users\mstack\source\repos\CSharpConsole>msbuild.exe /t:rebuild
Microsoft (R) Build Engine version 14.0.27522.0
Copyright (C) Microsoft Corporation. All rights reserved.
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 7/31/2018 10:27:21 AM.
Project "C:\Users\mstack\source\repos\CSharpConsole\CSharpConsole.sln" on node 1 (rebuild target(s)).
ValidateSolutionConfiguration:
Building solution configuration "Debug|Any CPU".
Project "C:\Users\mstack\source\repos\CSharpConsole\CSharpConsole.sln" (1) is building "C:\Users\mstack\source\repos\CS
harpConsole\CSharpConsole\CSharpConsole.csproj" (2) on node 1 (Rebuild target(s)).
CoreClean:
Deleting file "c:\users\mstack\source\repos\CSharpConsole\CSharpConsole\bin\Debug\CSharpConsole.exe.config".
Deleting file "c:\users\mstack\source\repos\CSharpConsole\CSharpConsole\bin\Debug\CSharpConsole.exe".
Deleting file "c:\users\mstack\source\repos\CSharpConsole\CSharpConsole\bin\Debug\CSharpConsole.pdb".
Deleting file "c:\users\mstack\source\repos\CSharpConsole\CSharpConsole\obj\Debug\CSharpConsole.exe".
Deleting file "c:\users\mstack\source\repos\CSharpConsole\CSharpConsole\obj\Debug\CSharpConsole.pdb".
Deleting file "C:\Users\mstack\source\repos\CSharpConsole\CSharpConsole\obj\Debug\CSharpConsole.csprojResolveAssembly
Reference.cache".
GenerateBindingRedirects:
No suggested binding redirects from ResolveAssemblyReferences.
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the i
nput files.
CreateProjectSpecificDirs:
Creating directory "C:\Users\mstack\source\repos\CSharpConsole\.sonarqube\conf\0".
CoreCompile:
C:\Program Files (x86)\MSBuild\14.0\bin\csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /platform:anycpu32bitpreferred
/errorreport:prompt /warn:4 /define:DEBUG;TRACE /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assembl
ies\Microsoft\Framework\.NETFramework\v4.6.1\Microsoft.CSharp.dll" /reference:"C:\Program Files (x86)\Reference Assem
blies\Microsoft\Framework\.NETFramework\v4.6.1\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\
Microsoft\Framework\.NETFramework\v4.6.1\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Mic
rosoft\Framework\.NETFramework\v4.6.1\System.Data.DataSetExtensions.dll" /reference:"C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\System.Data.dll" /reference:"C:\Program Files (x86)\Reference As
semblies\Microsoft\Framework\.NETFramework\v4.6.1\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies
\Microsoft\Framework\.NETFramework\v4.6.1\System.Net.Http.dll" /reference:"C:\Program Files (x86)\Reference Assemblie
s\Microsoft\Framework\.NETFramework\v4.6.1\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Mi
crosoft\Framework\.NETFramework\v4.6.1\System.Xml.Linq.dll" /debug+ /debug:full /filealign:512 /optimize- /out:obj\De
bug\CSharpConsole.exe /ruleset:C:\Users\mstack\source\repos\CSharpConsole\.sonarqube\conf\SonarQubeRoslyn-cs.ruleset
/errorlog:C:\Users\mstack\source\repos\CSharpConsole\CSharpConsole\bin\Debug\CSharpConsole.exe.RoslynCA.json /subsyst
emversion:6.00 /target:exe /warnaserror- /utf8output /analyzer:C:\Users\mstack\AppData\Local\Temp\.sonarqube\resource
s\1\Google.Protobuf.dll /analyzer:C:\Users\mstack\AppData\Local\Temp\.sonarqube\resources\1\SonarAnalyzer.CSharp.dll
/analyzer:C:\Users\mstack\AppData\Local\Temp\.sonarqube\resources\1\SonarAnalyzer.dll /additionalfile:C:\Users\mstack
\source\repos\CSharpConsole\.sonarqube\conf\cs\SonarLint.xml /additionalfile:C:\Users\mstack\source\repos\CSharpConso
le\.sonarqube\conf\0\ProjectOutFolderPath.txt Program.cs Properties\AssemblyInfo.cs "C:\Users\mstack\AppData\Local\Te
mp\.NETFramework,Version=v4.6.1.AssemblyAttributes.cs"
Using shared compilation with compiler from directory: C:\Program Files (x86)\MSBuild\14.0\Bin
Program.cs(21,35): warning S1075: Refactor your code not to use hardcoded absolute paths or URIs. [C:\Users\mstack\sour
ce\repos\CSharpConsole\CSharpConsole\CSharpConsole.csproj]
Program.cs(31,17): warning S1481: Remove this unused 'p' local variable. [C:\Users\mstack\source\repos\CSharpConsole\CS
harpConsole\CSharpConsole.csproj]
_CopyAppConfigFile:
Copying file from "App.config" to "bin\Debug\CSharpConsole.exe.config".
CopyFilesToOutputDirectory:
Copying file from "obj\Debug\CSharpConsole.exe" to "bin\Debug\CSharpConsole.exe".
CSharpConsole -> C:\Users\mstack\source\repos\CSharpConsole\CSharpConsole\bin\Debug\CSharpConsole.exe
Copying file from "obj\Debug\CSharpConsole.pdb" to "bin\Debug\CSharpConsole.pdb".
Done Building Project "C:\Users\mstack\source\repos\CSharpConsole\CSharpConsole\CSharpConsole.csproj" (Rebuild target(s
)).
Project "C:\Users\mstack\source\repos\CSharpConsole\CSharpConsole.sln" (1) is building "C:\Users\mstack\source\repos\CS
harpConsole\ClassLibrary3\ClassLibrary3.csproj" (3) on node 1 (Rebuild target(s)).
CoreClean:
Deleting file "C:\Users\mstack\source\repos\CSharpConsole\ClassLibrary3\bin\Debug\ClassLibrary3.dll".
Deleting file "C:\Users\mstack\source\repos\CSharpConsole\ClassLibrary3\bin\Debug\ClassLibrary3.pdb".
Deleting file "C:\Users\mstack\source\repos\CSharpConsole\ClassLibrary3\obj\Debug\ClassLibrary3.dll".
Deleting file "C:\Users\mstack\source\repos\CSharpConsole\ClassLibrary3\obj\Debug\ClassLibrary3.pdb".
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the i
nput files.
CreateProjectSpecificDirs:
Creating directory "C:\Users\mstack\source\repos\CSharpConsole\.sonarqube\conf\1".
CoreCompile:
C:\Program Files (x86)\MSBuild\14.0\bin\csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /d
efine:DEBUG;TRACE /highentropyva+ /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFra
mework\v4.6.1\Microsoft.CSharp.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETF
ramework\v4.6.1\mscorlib.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramewo
rk\v4.6.1\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\
v4.6.1\System.Data.DataSetExtensions.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework
\.NETFramework\v4.6.1\System.Data.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.N
ETFramework\v4.6.1\System.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramew
ork\v4.6.1\System.Net.Http.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFrame
work\v4.6.1\System.Xml.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework
\v4.6.1\System.Xml.Linq.dll" /debug+ /debug:full /filealign:512 /optimize- /out:obj\Debug\ClassLibrary3.dll /ruleset:
C:\Users\mstack\source\repos\CSharpConsole\.sonarqube\conf\SonarQubeRoslyn-cs.ruleset /errorlog:C:\Users\mstack\sourc
e\repos\CSharpConsole\ClassLibrary3\bin\Debug\ClassLibrary3.dll.RoslynCA.json /subsystemversion:6.00 /target:library
/warnaserror- /utf8output /analyzer:C:\Users\mstack\AppData\Local\Temp\.sonarqube\resources\1\Google.Protobuf.dll /an
alyzer:C:\Users\mstack\AppData\Local\Temp\.sonarqube\resources\1\SonarAnalyzer.CSharp.dll /analyzer:C:\Users\mstack\A
ppData\Local\Temp\.sonarqube\resources\1\SonarAnalyzer.dll /additionalfile:C:\Users\mstack\source\repos\CSharpConsole
\.sonarqube\conf\cs\SonarLint.xml /additionalfile:C:\Users\mstack\source\repos\CSharpConsole\.sonarqube\conf\1\Projec
tOutFolderPath.txt Class1.cs Properties\AssemblyInfo.cs "C:\Users\mstack\AppData\Local\Temp\.NETFramework,Version=v4.
6.1.AssemblyAttributes.cs"
Using shared compilation with compiler from directory: C:\Program Files (x86)\MSBuild\14.0\Bin
CopyFilesToOutputDirectory:
Copying file from "obj\Debug\ClassLibrary3.dll" to "bin\Debug\ClassLibrary3.dll".
ClassLibrary3 -> C:\Users\mstack\source\repos\CSharpConsole\ClassLibrary3\bin\Debug\ClassLibrary3.dll
Copying file from "obj\Debug\ClassLibrary3.pdb" to "bin\Debug\ClassLibrary3.pdb".
Done Building Project "C:\Users\mstack\source\repos\CSharpConsole\ClassLibrary3\ClassLibrary3.csproj" (Rebuild target(s
)).
Done Building Project "C:\Users\mstack\source\repos\CSharpConsole\CSharpConsole.sln" (rebuild target(s)).
Build succeeded.
"C:\Users\mstack\source\repos\CSharpConsole\CSharpConsole.sln" (rebuild target) (1) ->
"C:\Users\mstack\source\repos\CSharpConsole\CSharpConsole\CSharpConsole.csproj" (Rebuild target) (2) ->
(CoreCompile target) ->
Program.cs(21,35): warning S1075: Refactor your code not to use hardcoded absolute paths or URIs. [C:\Users\mstack\so
urce\repos\CSharpConsole\CSharpConsole\CSharpConsole.csproj]
Program.cs(31,17): warning S1481: Remove this unused 'p' local variable. [C:\Users\mstack\source\repos\CSharpConsole\
CSharpConsole\CSharpConsole.csproj]
2 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.75
C:\Users\mstack\source\repos\CSharpConsole>SonarScanner.MSBuild.exe end
SonarScanner for MSBuild 4.3.1
Using the .NET Framework version of the Scanner for MSBuild
Default properties file was found at C:\sonar-scanner-msbuild-4.3.1.1372\SonarQube.Analysis.xml
Loading analysis properties from C:\sonar-scanner-msbuild-4.3.1.1372\SonarQube.Analysis.xml
Post-processing started.
SONAR_SCANNER_OPTS is not configured. Setting it to the default value of -Xmx1024m
Calling the SonarQube Scanner...
INFO: Scanner configuration file: C:\sonar-scanner-msbuild-4.3.1.1372\sonar-scanner-3.2.0.1227\bin\..\conf\sonar-scanner
.properties
INFO: Project root configuration file: C:\Users\mstack\source\repos\CSharpConsole\.sonarqube\out\sonar-project.propertie
s
INFO: SonarQube Scanner 3.2.0.1227
INFO: Java 1.8.0_161 Oracle Corporation (64-bit)
INFO: Windows 7 6.1 amd64
INFO: SONAR_SCANNER_OPTS=-Xmx1024m
INFO: User cache: C:\Users\mstack\.sonar\cache
INFO: SonarQube server 7.2.0
INFO: Default locale: "en_US", source code encoding: "windows-1252" (analysis is platform dependent)
INFO: Publish mode
INFO: Load global settings
INFO: Load global settings (done) | time=69ms
INFO: Server id: AWQY1pGdg0uUlh1IQAmQ
INFO: User cache: C:\Users\mstack\.sonar\cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=51ms
INFO: Load/download plugins (done) | time=79ms
INFO: Loaded core extensions:
INFO: Process project properties
INFO: Load project repositories
INFO: Load project repositories (done) | time=70ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=31ms
INFO: Load active rules
INFO: Load active rules (done) | time=759ms
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=44ms
WARNING: WARN: SCM provider autodetection failed. No SCM provider claims to support this project. Please use sonar.scm.p
rovider to define SCM of your project.
INFO: Project key: project9000
INFO: Project base dir: C:\Users\mstack\source\repos\CSharpConsole
INFO: ------------- Scan ClassLibrary3
INFO: Load server rules
INFO: Load server rules (done) | time=147ms
INFO: Base dir: C:\Users\mstack\source\repos\CSharpConsole\ClassLibrary3
INFO: Working dir: C:\Users\mstack\source\repos\CSharpConsole\.sonarqube\out\.sonar\project9000_project9000_9159EDAF-754
6-4B8D-B366-4D08432B4D99
INFO: Source paths: Class1.cs, Properties/AssemblyInfo.cs
INFO: Source encoding: UTF-8, default locale: en_US
INFO: Index files
INFO: Excluded sources:
INFO: CSharpConsole/ClassLibrary3/**/*
INFO: CSharpConsole/ClassLibrary3
INFO: ClassLibrary3/**/*
INFO: 2 files indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: Quality profile for cs: Sonar way
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=1ms
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=0ms
INFO: No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
INFO: ------------- Scan CSharpConsole
INFO: Base dir: C:\Users\mstack\source\repos\CSharpConsole\CSharpConsole
INFO: Working dir: C:\Users\mstack\source\repos\CSharpConsole\.sonarqube\out\.sonar\project9000_project9000_315EB29A-C91
9-46DB-8681-5500BFD4F40D
INFO: Source paths: Program.cs, Properties/AssemblyInfo.cs, XMLFile1.xml, App.config, CSharpConsole.ruleset
INFO: Source encoding: UTF-8, default locale: en_US
INFO: Index files
INFO: Excluded sources:
INFO: CSharpConsole/ClassLibrary3/**/*
INFO: CSharpConsole/ClassLibrary3
INFO: ClassLibrary3/**/*
INFO: 5 files indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: Quality profile for cs: Sonar way
INFO: Quality profile for xml: Sonar way
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=1ms
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: 1 source files to be analyzed
INFO: 1/1 source files have been analyzed
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=132ms
INFO: Sensor XML Sensor [xml]
INFO: Sensor XML Sensor [xml] (done) | time=173ms
INFO: No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
INFO: ------------- Scan project9000
INFO: Base dir: C:\Users\mstack\source\repos\CSharpConsole
INFO: Working dir: C:\Users\mstack\source\repos\CSharpConsole\.sonarqube\out\.sonar
INFO: Source encoding: windows-1252, default locale: en_US
INFO: Index files
INFO: Excluded sources:
INFO: CSharpConsole/ClassLibrary3/**/*
INFO: CSharpConsole/ClassLibrary3
INFO: ClassLibrary3/**/*
INFO: 0 files indexed
INFO: 0 files ignored because of inclusion/exclusion patterns
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=0ms
INFO: Sensor C# [csharp]
INFO: Importing results from 6 proto files in 'C:\Users\mstack\source\repos\CSharpConsole\.sonarqube\out\1\output-cs'
INFO: Importing results from 6 proto files in 'C:\Users\mstack\source\repos\CSharpConsole\.sonarqube\out\0\output-cs'
INFO: Importing 2 Roslyn reports
INFO: Sensor C# [csharp] (done) | time=117ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=16ms
INFO: Sensor CPD Block Indexer
INFO: Sensor CPD Block Indexer (done) | time=1ms
INFO: No SCM system was detected. You can use the 'sonar.scm.provider' property to explicitly specify it.
INFO: 1 file had no CPD blocks
INFO: Calculating CPD for 3 files
INFO: CPD calculation finished
INFO: Analysis report generated in 114ms, dir size=41 KB
INFO: Analysis reports compressed in 41ms, zip size=17 KB
INFO: Analysis report uploaded in 25ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard?id=project9000
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis re
port
INFO: More about the report processing at http://localhost:9000/api/ce/task?id=AWTw86LtEEAs4V4nYVQq
INFO: Task total time: 4.283 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 6.297s
INFO: Final Memory: 16M/615M
INFO: ------------------------------------------------------------------------
The SonarQube Scanner has finished
10:27:36.454 Creating a summary markdown file...
10:27:36.488 Analysis results: http://localhost:9000/dashboard/index/project9000
10:27:36.491 Post-processing succeeded.