Sonar standalone scanner not scanning c# code

Sonarqube Server :- 6.7
Sonar Scanner plugin in VSTS - 4.3.0
C# Plugin :- 7.5

Below is detail log

2018-09-19T10:25:51.6214452Z ##[section]Starting: Run Code Analysis

2018-09-19T10:25:51.6217874Z ==============================================================================

2018-09-19T10:25:51.6218072Z Task : Run Code Analysis

2018-09-19T10:25:51.6218253Z Description : Run scanner and upload the results to the SonarQube server.

2018-09-19T10:25:51.6218421Z Version : 4.3.0

2018-09-19T10:25:51.6218561Z Author : sonarsource

2018-09-19T10:25:51.6218821Z Help : This task is not needed for Maven and Gradle projects since the scanner should be run as part of the build.

More Information

2018-09-19T10:25:51.6219122Z ==============================================================================

2018-09-19T10:25:52.0392351Z [command]C:\Windows\system32\cmd.exe /D /S /C “C:\agent1_work_tasks\SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055\4.3.0\sonar-scanner\bin\sonar-scanner.bat”

2018-09-19T10:25:52.3239608Z INFO: Scanner configuration file: C:\agent1_work_tasks\SonarQubeAnalyze_6d01813a-9589-4b15-8491-8164aeb38055\4.3.0\sonar-scanner\bin…\conf\

2018-09-19T10:25:52.3242411Z INFO: Project root configuration file: C:\agent1_work\159\s\

2018-09-19T10:25:52.3719774Z INFO: SonarQube Scanner

2018-09-19T10:25:52.3729869Z INFO: Java 1.8.0_181 Oracle Corporation (32-bit)

2018-09-19T10:25:52.3731599Z INFO: Windows Server 2012 R2 6.3 x86

2018-09-19T10:25:52.7746881Z INFO: User cache: C:\Windows\ServiceProfiles\NetworkService.sonar\cache

2018-09-19T10:25:52.9032729Z INFO: SonarQube server 6.7.0

2018-09-19T10:25:52.9036396Z INFO: Default locale: “en_US”, source code encoding: “UTF-8”

2018-09-19T10:25:53.1571809Z INFO: Publish mode

2018-09-19T10:25:53.3291219Z INFO: Load global settings

2018-09-19T10:25:53.4004108Z INFO: Load global settings (done) | time=78ms

2018-09-19T10:25:53.4087050Z INFO: Server id: AV-4X2pomHSxFfCe9B7Z

2018-09-19T10:25:53.4196726Z INFO: User cache: C:\Windows\ServiceProfiles\NetworkService.sonar\cache

2018-09-19T10:25:53.7136568Z INFO: Load plugins index

2018-09-19T10:25:53.7723288Z INFO: Load plugins index (done) | time=47ms

2018-09-19T10:25:54.3408934Z INFO: Process project properties

2018-09-19T10:25:54.3699440Z INFO: Load project repositories

2018-09-19T10:25:54.4922763Z INFO: Load project repositories (done) | time=109ms

2018-09-19T10:25:54.6058618Z INFO: Load quality profiles

2018-09-19T10:25:54.6376735Z INFO: Load quality profiles (done) | time=31ms

2018-09-19T10:25:54.6507144Z INFO: Load active rules

2018-09-19T10:25:55.0327380Z INFO: Load active rules (done) | time=375ms

2018-09-19T10:25:55.0355104Z INFO: Load metrics repository

2018-09-19T10:25:55.0564161Z INFO: Load metrics repository (done) | time=16ms

2018-09-19T10:25:55.0984653Z INFO: Project key: OTIS-API

2018-09-19T10:25:55.0992194Z INFO: ------------- Scan Customer-Portal-API

2018-09-19T10:25:55.2239390Z INFO: Load server rules

2018-09-19T10:25:55.2701668Z INFO: Load server rules (done) | time=47ms

2018-09-19T10:25:55.3054015Z INFO: Base dir: C:\agent1_work\159\s

2018-09-19T10:25:55.3054953Z INFO: Working dir: C:\agent1_work\159\s.scannerwork

2018-09-19T10:25:55.3082409Z INFO: Source paths: CX-API, CX-API.Tests, IO-Swagger

2018-09-19T10:25:55.3083170Z INFO: Source encoding: UTF-8, default locale: en_US

2018-09-19T10:25:55.4299270Z INFO: Index files

2018-09-19T10:25:55.5612656Z INFO: 178 files indexed

2018-09-19T10:25:55.5621001Z INFO: Quality profile for cs: Sonar way

2018-09-19T10:25:55.5621358Z INFO: Quality profile for xml: Sonar way

2018-09-19T10:25:56.3476142Z INFO: Sensor C# [csharp]

2018-09-19T10:25:56.3554686Z INFO: Importing analysis results from C:\agent1_work\159\s\null\output-cs

2018-09-19T10:25:56.3710008Z ##[error]WARN: Protobuf file not found: null\output-cs\encoding.pb

2018-09-19T10:25:56.3711071Z WARN: Protobuf file not found: null\output-cs\encoding.pb

2018-09-19T10:25:56.3761234Z ##[error]WARN: Protobuf file not found: null\output-cs\metrics.pb

2018-09-19T10:25:56.3767580Z WARN: Protobuf file not found: null\output-cs\metrics.pb

2018-09-19T10:25:56.3784839Z ##[error]WARN: Protobuf file not found: null\output-cs\issues.pb

2018-09-19T10:25:56.3786376Z WARN: Protobuf file not found: null\output-cs\issues.pb

2018-09-19T10:25:56.3814594Z ##[error]WARN: Protobuf file not found: null\output-cs\token-type.pb

2018-09-19T10:25:56.3817630Z WARN: Protobuf file not found: null\output-cs\token-type.pb

2018-09-19T10:25:56.3852266Z ##[error]WARN: Protobuf file not found: null\output-cs\symrefs.pb

2018-09-19T10:25:56.3853594Z WARN: Protobuf file not found: null\output-cs\symrefs.pb

2018-09-19T10:25:56.3877912Z ##[error]WARN: Protobuf file not found: null\output-cs\token-cpd.pb

2018-09-19T10:25:56.3880613Z WARN: Protobuf file not found: null\output-cs\token-cpd.pb

2018-09-19T10:25:56.3880961Z INFO: Sensor C# [csharp] (done) | time=47ms

2018-09-19T10:25:56.3881283Z INFO: Sensor SonarJavaXmlFileSensor [java]

2018-09-19T10:25:56.4082961Z INFO: 1 source files to be analyzed

2018-09-19T10:25:56.4663995Z INFO: Sensor SonarJavaXmlFileSensor [java] (done) | time=63ms

2018-09-19T10:25:56.4664626Z INFO: Sensor XML Sensor [xml]

2018-09-19T10:25:56.4665116Z INFO: 1/1 source files have been analyzed

2018-09-19T10:25:56.8015200Z INFO: Sensor XML Sensor [xml] (done) | time=344ms

2018-09-19T10:25:56.8018023Z INFO: Sensor Analyzer for “php.ini” files [php]

2018-09-19T10:25:56.8049499Z INFO: Sensor Analyzer for “php.ini” files [php] (done) | time=0ms

2018-09-19T10:25:56.8050383Z INFO: Sensor C# Tests Coverage Report Import [csharp]

2018-09-19T10:25:56.8387889Z INFO: Sensor C# Tests Coverage Report Import [csharp] (done) | time=31ms

2018-09-19T10:25:56.8390534Z INFO: Sensor [Deprecated] C# Integration Tests Coverage Report Import [csharp]

2018-09-19T10:25:56.8391238Z INFO: Sensor [Deprecated] C# Integration Tests Coverage Report Import [csharp] (done) | time=0ms

2018-09-19T10:25:56.8391808Z INFO: Sensor C# Unit Test Results Import [csharp]

2018-09-19T10:25:56.8392337Z INFO: Sensor C# Unit Test Results Import [csharp] (done) | time=0ms

2018-09-19T10:25:56.8392801Z INFO: Sensor Zero Coverage Sensor

2018-09-19T10:25:56.8812602Z INFO: Sensor Zero Coverage Sensor (done) | time=47ms

2018-09-19T10:25:56.8813606Z INFO: Sensor CPD Block Indexer

2018-09-19T10:25:56.8814241Z INFO: Sensor CPD Block Indexer (done) | time=0ms

2018-09-19T10:25:57.0690127Z INFO: SCM provider for this project is: git

2018-09-19T10:25:57.0697251Z INFO: 5 files to be analyzed

2018-09-19T10:25:57.8484129Z INFO: 0/5 files analyzed

2018-09-19T10:25:57.8491667Z ##[error]WARN: Missing blame information for the following files:

WARN: * CX-API.Tests/obj/RELEASE/netcoreapp2.0/CX-API.Tests.AssemblyInfo.cs

WARN: * CX-API.Tests/obj/RELEASE/netcoreapp2.0/CX-API.Tests.Program.cs

WARN: * CX-API/bin/RELEASE/netcoreapp2.0/OtisCX.xml

WARN: * CX-API/obj/RELEASE/netcoreapp2.0/OtisCX.AssemblyInfo.cs

WARN: * IO-Swagger/obj/RELEASE/netstandard2.0/IO-Swagger.AssemblyInfo.cs

WARN: This may lead to missing/broken features in SonarQube

2018-09-19T10:25:57.8493780Z WARN: Missing blame information for the following files:

2018-09-19T10:25:57.8494221Z WARN: * CX-API.Tests/obj/RELEASE/netcoreapp2.0/CX-API.Tests.AssemblyInfo.cs

2018-09-19T10:25:57.8494581Z WARN: * CX-API.Tests/obj/RELEASE/netcoreapp2.0/CX-API.Tests.Program.cs

2018-09-19T10:25:57.8494928Z WARN: * CX-API/bin/RELEASE/netcoreapp2.0/OtisCX.xml

2018-09-19T10:25:57.8495254Z WARN: * CX-API/obj/RELEASE/netcoreapp2.0/OtisCX.AssemblyInfo.cs

2018-09-19T10:25:57.8495843Z WARN: * IO-Swagger/obj/RELEASE/netstandard2.0/IO-Swagger.AssemblyInfo.cs

2018-09-19T10:25:57.8496224Z WARN: This may lead to missing/broken features in SonarQube

2018-09-19T10:25:57.8496575Z INFO: Calculating CPD for 0 files

2018-09-19T10:25:57.8496894Z INFO: CPD calculation finished

2018-09-19T10:25:58.1913339Z INFO: Analysis report generated in 329ms, dir size=946 KB

2018-09-19T10:25:58.3420227Z INFO: Analysis reports compressed in 156ms, zip size=196 KB

2018-09-19T10:25:58.3961351Z INFO: Analysis report uploaded in 47ms

2018-09-19T10:25:58.3972559Z INFO: ANALYSIS SUCCESSFUL, you can browse

2018-09-19T10:25:58.3973028Z INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report

2018-09-19T10:25:58.3973415Z INFO: More about the report processing at

2018-09-19T10:25:58.5892928Z INFO: Task total time: 4.718 s

2018-09-19T10:25:58.6838251Z INFO: ------------------------------------------------------------------------

2018-09-19T10:25:58.6838672Z INFO: EXECUTION SUCCESS

2018-09-19T10:25:58.6839128Z INFO: ------------------------------------------------------------------------

2018-09-19T10:25:58.6839526Z INFO: Total time: 6.375s

2018-09-19T10:25:58.7329654Z INFO: Final Memory: 12M/111M

2018-09-19T10:25:58.7330481Z INFO: ------------------------------------------------------------------------

If you are scanning C# code you need to select the Integrate with MSBuild option in the Prepare step, not Use standalone scanner.

But… What if I need to scan other file types ? Like TypeScript files, CSS, and so on?

I mean, the standalone scanner should still be able to scan CS files! It’s not like it’s a totally different scanner isn’t it?

Is there a possible workaround?


Hi @Indigo744,

The Scanner for MSBuild (“S4MSB”) does quite a bit of extra work before calling the command line scanner. The C#/VB.NET rules are implemented as Roslyn analyzers so they are not executed by the command line scanner - they are executed by the C#/VB.NET compiler as part of the MSBuild step. The S4MSB generates a ruleset corresponding to the selected Quality Profile, integrates the SonarC/VB.Net rules into the build, and collects information about the files to be analyzed, before finally generating a file and calling the command line scanner. Of course, you don’t have to use the S4MSB - you can handle all of those steps yourself if you want to.

If those files are referenced by an MSBuild project (e.g. in an ASP.NET project) then they will automatically be picked up the S4MSB and passed to the command line scanner to be analysed.
See the thread Typescript files are not analyzed with Scanner for MSBuild for more information and alternatives.

Thanks for your reply. Now I understand better how this works.

Indeed, after having referenced the additional TS/JS/CSS files, they get picked up by MSBuild analyzer.