SonarQube and SonarC# and Vulnerabilities not scanning

Hi,

I’m running the following setup:

SonarQube: 7.4 (build 18908)

SonarC#: 7.9.0.7583

MSBuild: Microsoft ® Build Engine version 15.9.20+g88f5fadfbe for .NET Framework

dotnet.exe: 2.1.500

I apologise for the big image, but as a new user I’m only allowed to upload one image in a post, and this is better explained with screenshots…

I’ve even gone as far as using older versions of SonarQube (7.2 and 7.0) with the exact same results.

We need to scan for vulnerabilities in C# 7 constructs, for which I need to have at least SonarC# 7.5 installed.

Does anybody have any ideas on what could be causing this? Your help will be much appreciated! Please find below the output log of one of the failed scans…

Thank you!

Scan Output:

C:\Dev\CNP\temp\TestClassLibraryOld> SonarScanner.MSBuild.exe begin /k:“test1-old” /d:sonar.host.url=“http://localhost:9000” /d:sonar.login=“dd17ff1bf51fd6e50d0f4269308de2a9c6253c31”
SonarScanner for MSBuild 4.4.2
Using the .NET Framework version of the Scanner for MSBuild
Default properties file was found at C:\Dev\sonarqube\scanners\net46\SonarQube.Analysis.xml
Loading analysis properties from C:\Dev\sonarqube\scanners\net46\SonarQube.Analysis.xml
Pre-processing started.
Preparing working directories…
11:28:27.698 Updating build integration targets…
11:28:27.716 Fetching analysis configuration settings…
11:28:28.437 Provisioning analyzer assemblies for cs…
11:28:28.437 Installing required Roslyn analyzers…
11:28:28.78 Provisioning analyzer assemblies for vbnet…
11:28:28.78 Installing required Roslyn analyzers…
11:28:28.811 Pre-processing succeeded.
C:\Dev\CNP\temp\TestClassLibraryOld> MSBuild.exe /t:Rebuild
Microsoft ® Build Engine version 15.9.20+g88f5fadfbe for .NET Framework
Copyright © 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 4/12/2018 11:28:37 AM.
Project “C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLibraryOld.sln” on node 1 (Rebuild target(s)).
ValidateSolutionConfiguration:
Building solution configuration “Debug|Any CPU”.
Project “C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLibraryOld.sln” (1) is building “C:\Dev\CNP\temp\TestClassLibraryOld\TestCo
nsole\TestConsole.csproj” (2) on node 1 (Rebuild target(s)).
CoreClean:
Deleting file “C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\bin\Debug\TestConsole.exe”.
Deleting file “C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\bin\Debug\TestConsole.pdb”.
Deleting file “C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\bin\Debug\TestClassLib.dll”.
Deleting file “C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\bin\Debug\TestClassLib.pdb”.
Deleting file “C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\obj\Debug\TestConsole.exe”.
Deleting file “C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\obj\Debug\TestConsole.pdb”.
Deleting file “C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\obj\Debug\TestConsole.csprojAssemblyReference.cache”.
Deleting file “C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\obj\Debug\TestConsole.csproj.CoreCompileInputs.cache”.
Deleting file “C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\obj\Debug\TestConsole.csproj.CopyComplete”.
Project “C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\TestConsole.csproj” (2) is building “C:\Dev\CNP\temp\TestClassLibraryOld
\TestClassLib\TestClassLib.csproj” (3:2) on node 1 (Clean target(s)).
CoreClean:
Deleting file “C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLib\bin\Debug\TestClassLib.dll”.
Deleting file “C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLib\bin\Debug\TestClassLib.pdb”.
Deleting file “C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLib\obj\Debug\TestClassLib.dll”.
Deleting file “C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLib\obj\Debug\TestClassLib.pdb”.
Deleting file “C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLib\obj\Debug\TestClassLib.csprojAssemblyReference.cache”.
Deleting file “C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLib\obj\Debug\TestClassLib.csproj.CoreCompileInputs.cache”.
Done Building Project “C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLib\TestClassLib.csproj” (Clean target(s)).

Project “C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\TestConsole.csproj” (2) is building “C:\Dev\CNP\temp\TestClassLibraryOld
\TestClassLib\TestClassLib.csproj” (3:3) on node 1 (default targets).
GenerateTargetFrameworkMonikerAttribute:
Skipping target “GenerateTargetFrameworkMonikerAttribute” because all output files are up-to-date with respect to the input files
.
CreateProjectSpecificDirs:
Creating directory “C:\Dev\CNP\temp\TestClassLibraryOld.sonarqube\conf\0”.
CoreCompile:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Roslyn\csc.exe /noconfig /nowarn:1701,1702 /nos
tdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE /highentropyva- /reference:“C:\Program Files (x86)\Reference Assemblies
Microsoft\Framework.NETFramework\v4.0\Microsoft.CSharp.dll” /reference:“C:\Program Files (x86)\Reference Assemblies\Microsoft
Framework.NETFramework\v4.0\mscorlib.dll” /reference:“C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFram
ework\v4.0\System.Core.dll” /reference:“C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\Syst
em.Data.DataSetExtensions.dll” /reference:“C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\S
ystem.Data.dll” /reference:“C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.dll” /ref
erence:“C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Xml.dll” /reference:“C:\Progr
am Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Xml.Linq.dll” /debug+ /debug:full /filealign:
512 /optimize- /out:obj\Debug\TestClassLib.dll /ruleset:C:\Dev\CNP\temp\TestClassLibraryOld.sonarqube\conf\0\merged.ruleset /e
rrorlog:C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLib\bin\Debug\TestClassLib.dll.RoslynCA.json /target:library /warnaserror-
/utf8output /analyzer:C:\Users\bb83281\AppData\Local\Temp.sonarqube\resources\3\Google.Protobuf.dll /analyzer:C:\Users\bb8328
1\AppData\Local\Temp.sonarqube\resources\3\SonarAnalyzer.CSharp.dll /analyzer:C:\Users\bb83281\AppData\Local\Temp.sonarqube\r
esources\3\SonarAnalyzer.dll /additionalfile:C:\Dev\CNP\temp\TestClassLibraryOld.sonarqube\conf\cs\SonarLint.xml /additionalfi
le:C:\Dev\CNP\temp\TestClassLibraryOld.sonarqube\conf\0\ProjectOutFolderPath.txt Class1.cs Properties\AssemblyInfo.cs “C:\User
s\bb83281\AppData\Local\Temp.NETFramework,Version=v4.0.AssemblyAttributes.cs”
Using shared compilation with compiler from directory: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\1
5.0\Bin\Roslyn
Class1.cs(18,30): warning CS0168: The variable ‘ex’ is declared but never used [C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLib
TestClassLib.csproj]
Class1.cs(1,1): warning S1451: Add or update the header of this file. [C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLib\TestClass
Lib.csproj]
Properties\AssemblyInfo.cs(1,1): warning S1451: Add or update the header of this file. [C:\Dev\CNP\temp\TestClassLibraryOld\TestC
lassLib\TestClassLib.csproj]
Class1.cs(19,13): warning S108: Either remove or fill this block of code. [C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLib\TestC
lassLib.csproj]
CSC : warning S3990: Mark this assembly with ‘System.CLSCompliantAttribute’ [C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLib\Tes
tClassLib.csproj]
CopyFilesToOutputDirectory:
Copying file from “obj\Debug\TestClassLib.dll” to “bin\Debug\TestClassLib.dll”.
TestClassLib -> C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLib\bin\Debug\TestClassLib.dll
Copying file from “obj\Debug\TestClassLib.pdb” to “bin\Debug\TestClassLib.pdb”.
Done Building Project “C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLib\TestClassLib.csproj” (default targets).

GenerateTargetFrameworkMonikerAttribute:
Skipping target “GenerateTargetFrameworkMonikerAttribute” because all output files are up-to-date with respect to the input files
.
CreateProjectSpecificDirs:
Creating directory “C:\Dev\CNP\temp\TestClassLibraryOld.sonarqube\conf\1”.
CoreCompile:
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Roslyn\csc.exe /noconfig /nowarn:1701,1702 /nos
tdlib+ /platform:AnyCPU /errorreport:prompt /warn:4 /define:DEBUG;TRACE /highentropyva- /reference:“C:\Program Files (x86)\Refe
rence Assemblies\Microsoft\Framework.NETFramework\v4.0\Microsoft.CSharp.dll” /reference:“C:\Program Files (x86)\Reference Asse
mblies\Microsoft\Framework.NETFramework\v4.0\mscorlib.dll” /reference:“C:\Program Files (x86)\Reference Assemblies\Microsoft\F
ramework.NETFramework\v4.0\System.Core.dll” /reference:“C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFr
amework\v4.0\System.Data.DataSetExtensions.dll” /reference:“C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NE
TFramework\v4.0\System.Data.dll” /reference:“C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0
\System.dll” /reference:“C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Xml.dll” /re
ference:“C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0\System.Xml.Linq.dll” /reference:C:
Dev\CNP\temp\TestClassLibraryOld\TestClassLib\bin\Debug\TestClassLib.dll /debug+ /debug:full /filealign:512 /optimize- /out:obj
\Debug\TestConsole.exe /ruleset:C:\Dev\CNP\temp\TestClassLibraryOld.sonarqube\conf\1\merged.ruleset /errorlog:C:\Dev\CNP\temp
TestClassLibraryOld\TestConsole\bin\Debug\TestConsole.exe.RoslynCA.json /target:exe /warnaserror- /utf8output /analyzer:C:\User
s\bb83281\AppData\Local\Temp.sonarqube\resources\3\Google.Protobuf.dll /analyzer:C:\Users\bb83281\AppData\Local\Temp.sonarqub
e\resources\3\SonarAnalyzer.CSharp.dll /analyzer:C:\Users\bb83281\AppData\Local\Temp.sonarqube\resources\3\SonarAnalyzer.dll /
additionalfile:C:\Dev\CNP\temp\TestClassLibraryOld.sonarqube\conf\cs\SonarLint.xml /additionalfile:C:\Dev\CNP\temp\TestClassLi
braryOld.sonarqube\conf\1\ProjectOutFolderPath.txt Program.cs Properties\AssemblyInfo.cs “C:\Users\bb83281\AppData\Local\Temp
.NETFramework,Version=v4.0.AssemblyAttributes.cs”
Using shared compilation with compiler from directory: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\1
5.0\Bin\Roslyn
Program.cs(16,30): warning CS0168: The variable ‘ex’ is declared but never used [C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole
TestConsole.csproj]
Program.cs(20,17): warning CS0219: The variable ‘test2’ is assigned but its value is never used [C:\Dev\CNP\temp\TestClassLibrary
Old\TestConsole\TestConsole.csproj]
Program.cs(1,1): warning S1451: Add or update the header of this file. [C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\TestConso
le.csproj]
Properties\AssemblyInfo.cs(1,1): warning S1451: Add or update the header of this file. [C:\Dev\CNP\temp\TestClassLibraryOld\TestC
onsole\TestConsole.csproj]
Program.cs(7,11): warning S1118: Add a ‘protected’ constructor or the ‘static’ keyword to the class declaration. [C:\Dev\CNP\temp
\TestClassLibraryOld\TestConsole\TestConsole.csproj]
Program.cs(17,13): warning S108: Either remove or fill this block of code. [C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\TestC
onsole.csproj]
Program.cs(22,20): warning S2757: Was ‘+=’ meant instead? [C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\TestConsole.csproj]
Program.cs(22,19): warning S1854: Remove this useless assignment to local variable ‘test2’. [C:\Dev\CNP\temp\TestClassLibraryOld
TestConsole\TestConsole.csproj]
Program.cs(13,21): warning S1481: Remove the unused local variable ‘test’. [C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\TestC
onsole.csproj]
Program.cs(24,17): warning S1481: Remove the unused local variable ‘hashProvider1’. [C:\Dev\CNP\temp\TestClassLibraryOld\TestCons
ole\TestConsole.csproj]
Program.cs(25,17): warning S1481: Remove the unused local variable ‘hashProvider2’. [C:\Dev\CNP\temp\TestClassLibraryOld\TestCons
ole\TestConsole.csproj]
Program.cs(26,17): warning S1481: Remove the unused local variable ‘hashProvider3’. [C:\Dev\CNP\temp\TestClassLibraryOld\TestCons
ole\TestConsole.csproj]
Program.cs(27,17): warning S1481: Remove the unused local variable ‘hashProvider4’. [C:\Dev\CNP\temp\TestClassLibraryOld\TestCons
ole\TestConsole.csproj]
CSC : warning S3990: Mark this assembly with ‘System.CLSCompliantAttribute’ [C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\Test
Console.csproj]
_CopyFilesMarkedCopyLocal:
Copying file from “C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLib\bin\Debug\TestClassLib.pdb” to “bin\Debug\TestClassLib.pdb”
.
Copying file from “C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLib\bin\Debug\TestClassLib.dll” to “bin\Debug\TestClassLib.dll”
.
Creating “C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\obj\Debug\TestConsole.csproj.CopyComplete” because “AlwaysCreate” was
specified.
CopyFilesToOutputDirectory:
Copying file from “obj\Debug\TestConsole.exe” to “bin\Debug\TestConsole.exe”.
TestConsole -> C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\bin\Debug\TestConsole.exe
Copying file from “obj\Debug\TestConsole.pdb” to “bin\Debug\TestConsole.pdb”.
Done Building Project “C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\TestConsole.csproj” (Rebuild target(s)).

Done Building Project “C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLibraryOld.sln” (Rebuild target(s)).

Build succeeded.

“C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLibraryOld.sln” (Rebuild target) (1) ->
“C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\TestConsole.csproj” (Rebuild target) (2) ->
“C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLib\TestClassLib.csproj” (default target) (3:3) ->
(CoreCompile target) ->
Class1.cs(18,30): warning CS0168: The variable ‘ex’ is declared but never used [C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLi
b\TestClassLib.csproj]
Class1.cs(1,1): warning S1451: Add or update the header of this file. [C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLib\TestCla
ssLib.csproj]
Properties\AssemblyInfo.cs(1,1): warning S1451: Add or update the header of this file. [C:\Dev\CNP\temp\TestClassLibraryOld\Tes
tClassLib\TestClassLib.csproj]
Class1.cs(19,13): warning S108: Either remove or fill this block of code. [C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLib\Tes
tClassLib.csproj]
CSC : warning S3990: Mark this assembly with ‘System.CLSCompliantAttribute’ [C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLib\T
estClassLib.csproj]

“C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLibraryOld.sln” (Rebuild target) (1) ->
“C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\TestConsole.csproj” (Rebuild target) (2) ->
Program.cs(16,30): warning CS0168: The variable ‘ex’ is declared but never used [C:\Dev\CNP\temp\TestClassLibraryOld\TestConsol
e\TestConsole.csproj]
Program.cs(20,17): warning CS0219: The variable ‘test2’ is assigned but its value is never used [C:\Dev\CNP\temp\TestClassLibra
ryOld\TestConsole\TestConsole.csproj]
Program.cs(1,1): warning S1451: Add or update the header of this file. [C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\TestCon
sole.csproj]
Properties\AssemblyInfo.cs(1,1): warning S1451: Add or update the header of this file. [C:\Dev\CNP\temp\TestClassLibraryOld\Tes
tConsole\TestConsole.csproj]
Program.cs(7,11): warning S1118: Add a ‘protected’ constructor or the ‘static’ keyword to the class declaration. [C:\Dev\CNP\te
mp\TestClassLibraryOld\TestConsole\TestConsole.csproj]
Program.cs(17,13): warning S108: Either remove or fill this block of code. [C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\Tes
tConsole.csproj]
Program.cs(22,20): warning S2757: Was ‘+=’ meant instead? [C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\TestConsole.csproj]
Program.cs(22,19): warning S1854: Remove this useless assignment to local variable ‘test2’. [C:\Dev\CNP\temp\TestClassLibraryOl
d\TestConsole\TestConsole.csproj]
Program.cs(13,21): warning S1481: Remove the unused local variable ‘test’. [C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\Tes
tConsole.csproj]
Program.cs(24,17): warning S1481: Remove the unused local variable ‘hashProvider1’. [C:\Dev\CNP\temp\TestClassLibraryOld\TestCo
nsole\TestConsole.csproj]
Program.cs(25,17): warning S1481: Remove the unused local variable ‘hashProvider2’. [C:\Dev\CNP\temp\TestClassLibraryOld\TestCo
nsole\TestConsole.csproj]
Program.cs(26,17): warning S1481: Remove the unused local variable ‘hashProvider3’. [C:\Dev\CNP\temp\TestClassLibraryOld\TestCo
nsole\TestConsole.csproj]
Program.cs(27,17): warning S1481: Remove the unused local variable ‘hashProvider4’. [C:\Dev\CNP\temp\TestClassLibraryOld\TestCo
nsole\TestConsole.csproj]
CSC : warning S3990: Mark this assembly with ‘System.CLSCompliantAttribute’ [C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole\Te
stConsole.csproj]

19 Warning(s)
0 Error(s)

Time Elapsed 00:00:02.28
C:\Dev\CNP\temp\TestClassLibraryOld> SonarScanner.MSBuild.exe end /d:sonar.login=“dd17ff1bf51fd6e50d0f4269308de2a9c6253c31”
SonarScanner for MSBuild 4.4.2
Using the .NET Framework version of the Scanner for MSBuild
Default properties file was found at C:\Dev\sonarqube\scanners\net46\SonarQube.Analysis.xml
Loading analysis properties from C:\Dev\sonarqube\scanners\net46\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:\Dev\sonarqube\scanners\net46\sonar-scanner-3.2.0.1227\bin…\conf\sonar-scanner.properties
INFO: Project root configuration file: C:\Dev\CNP\temp\TestClassLibraryOld.sonarqube\out\sonar-project.properties
INFO: SonarQube Scanner 3.2.0.1227
INFO: Java 1.8.0_191 Oracle Corporation (64-bit)
INFO: Windows 8.1 6.3 amd64
INFO: SONAR_SCANNER_OPTS=-Xmx1024m
INFO: User cache: C:\Users\bb83281.sonar\cache
INFO: SonarQube server 7.4.0
INFO: Default locale: “en_AU”, source code encoding: “windows-1252” (analysis is platform dependent)
INFO: Publish mode
INFO: Load global settings
INFO: Load global settings (done) | time=87ms
INFO: Server id: BF41A1F2-AWdyF_DrUEMrtMaMqadT
INFO: User cache: C:\Users\bb83281.sonar\cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=63ms
INFO: Load/download plugins (done) | time=94ms
INFO: Loaded core extensions:
INFO: Process project properties
INFO: Load project repositories
INFO: Load project repositories (done) | time=94ms
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=50ms
INFO: Load active rules
INFO: Load active rules (done) | time=1430ms
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=32ms
INFO: Project key: test1-old
INFO: Project base dir: C:\Dev\CNP\temp\TestClassLibraryOld
INFO: ------------- Scan TestClassLib
INFO: Base dir: C:\Dev\CNP\temp\TestClassLibraryOld\TestClassLib
INFO: Working dir: C:\Dev\CNP\temp\TestClassLibraryOld.sonarqube\out.sonar\test1-old_test1-old_C7CB100C-5AA4-4EC2-AAF7-35AE127AB7FD
INFO: Source paths: Class1.cs, Properties/AssemblyInfo.cs
INFO: Source encoding: UTF-8, default locale: en_AU
INFO: Load server rules
INFO: Load server rules (done) | time=422ms
INFO: Index files
INFO: 2 files indexed
INFO: Quality profile for cs: Test Profile
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=16ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=0ms
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=0ms
INFO: SCM Publisher is disabled
INFO: ------------- Scan TestConsole
INFO: Base dir: C:\Dev\CNP\temp\TestClassLibraryOld\TestConsole
INFO: Working dir: C:\Dev\CNP\temp\TestClassLibraryOld.sonarqube\out.sonar\test1-old_test1-old_8210491E-C772-4DEE-98BF-BE748478295B
INFO: Source paths: Program.cs, Properties/AssemblyInfo.cs
INFO: Source encoding: UTF-8, default locale: en_AU
INFO: Index files
INFO: 2 files indexed
INFO: Quality profile for cs: Test Profile
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=0ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=0ms
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=0ms
INFO: SCM Publisher is disabled
INFO: ------------- Scan test1-old
INFO: Base dir: C:\Dev\CNP\temp\TestClassLibraryOld
INFO: Working dir: C:\Dev\CNP\temp\TestClassLibraryOld.sonarqube\out.sonar
INFO: Source encoding: windows-1252, default locale: en_AU
INFO: Index files
INFO: 0 files indexed
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=0ms
INFO: Sensor SonarJavaXmlFileSensor [java]
INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=0ms
INFO: Sensor C# [csharp]
INFO: Importing results from 6 proto files in ‘C:\Dev\CNP\temp\TestClassLibraryOld.sonarqube\out\0\output-cs’
INFO: Importing results from 6 proto files in ‘C:\Dev\CNP\temp\TestClassLibraryOld.sonarqube\out\1\output-cs’
INFO: Importing 2 Roslyn reports
INFO: Sensor C# [csharp] (done) | time=219ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=16ms
INFO: SCM Publisher is disabled
INFO: Calculating CPD for 4 files
INFO: CPD calculation finished
INFO: Analysis report generated in 156ms, dir size=48 KB
INFO: Analysis reports compressed in 47ms, zip size=19 KB
INFO: Analysis report uploaded in 31ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard?id=test1-old
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at http://localhost:9000/api/ce/task?id=AWd3QubeK70VlHRWGTed
INFO: Task total time: 5.258 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 6.943s
INFO: Final Memory: 14M/375M
INFO: ------------------------------------------------------------------------
The SonarQube Scanner has finished
11:28:52.7 Creating a summary markdown file…
11:28:52.701 Analysis results: http://localhost:9000/dashboard/index/test1-old
11:28:52.701 Post-processing succeeded.
C:\Dev\CNP\temp\TestClassLibraryOld>

Hi @mjordaan,

Thanks for the detailed question, it is very much appreciated! I suspect the problem is caused because your project has “Test” in its name, which makes SonarC# to consider it as a Test project and disable reporting for certain rules.

All rules have this “Analysis Scope” property that’s set in their corresponding RSPEC (for example: https://jira.sonarsource.com/browse/RSPEC-2076) and I think all of the Vulnerabilities are set to Main Sources which excludes tests. SonarC# started to read this value since version 7.1 and that’s consistent with your observations.

To resolve the problem you could set the sonar.msbuild.testProjectPattern to a .NET regular expression that matches the names of your regular test projects, but does not match this one. See this article for more details:
https://docs.sonarqube.org/display/SCAN/Miscellaneous+Advanced+Usages

1 Like

Brilliant, thanks a lot Valeri. I can confirm that was the exact problem, everything scans as expected now! Appreciate the help!

1 Like