SonarQube not showing any c# analysis with gradle plugin org.sonarqube.2.6.2

Hi,

We’re upgrading our SonarQube server, and I dont seem to be able to get it to process any C# code. With the old version of gradleplugin and sonarqube, we just had to set a few properties, but now I cant see what property I’ve not set, which means its ignoring all the c# code now.

SonarQube 7.9.1
Gradle 5.6.2, or 4.0.1,
gradle plugin: org.sonarqube version 2.6.2
SonarC# family 7.16 build 8981

I’ve even tried this now with a very simple demo c# app and I get the same result - zero c# analysis

when I set the:
systemProp.sonar.cs.analyzer.projectOutPaths
property after I’ve run it once and worked out where the output-cs directory is, it works. but I have to hardcode this.
It always seems to find the c# files, (so long as the sonar.sources property is set), but doesnt show any analysis on the server

Initialized native services in: C:\Users\ukrbat.gradle\native
Removing 0 daemon stop events from registry
Previous Daemon (22684) stopped at Tue Sep 17 16:05:44 BST 2019 stop command received
Previous Daemon (13356) stopped at Tue Sep 17 15:39:55 BST 2019 after running out of JVM memory
Previous Daemon (21040) stopped at Tue Sep 17 15:49:52 BST 2019 after running out of JVM memory
Starting a Gradle Daemon, 3 stopped Daemons could not be reused, use --status for details
Starting process ‘Gradle build daemon’. Working directory: C:\Users\ukrbat.gradle\daemon\5.6.2 Command: C:\Program Files\Java\jdk1.8.0_201\bin\java.exe -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -Xms256m -Xmx512m -Dfile.encoding=windows-1252 -Duser.country=GB -Duser.language=en -Duser.variant -cp C:\Users\ukrbat.gradle\wrapper\dists\gradle-5.6.2-bin\3clyn6icets6f02ptgd5hlmou\gradle-5.6.2\lib\gradle-launcher-5.6.2.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 5.6.2
Successfully started process ‘Gradle build daemon’
An attempt to start the daemon took 4.389 secs.
The client will now receive all logging from the daemon (pid: 31296). The daemon log file: C:\Users\ukrbat.gradle\daemon\5.6.2\daemon-31296.out.log
Starting build in new daemon [memory: 477.6 MB]
Using 4 worker leases.
Starting Build
Settings evaluated using settings file ‘C:\Users\ukrbat\Documents\Visual Studio 2017\Projects\ClassLibrary1\settings.gradle’.
Projects loaded. Root project using build file ‘C:\Users\ukrbat\Documents\Visual Studio 2017\Projects\ClassLibrary1\build.gradle’.
Included projects: [root project ‘ClassLibrary1’]

Configure project :
Evaluating root project ‘ClassLibrary1’ using build file ‘C:\Users\ukrbat\Documents\Visual Studio 2017\Projects\ClassLibrary1\build.gradle’.
All projects evaluated.
Selected primary task ‘sonarqube’ from project :
Tasks to be executed: [task ‘:sonarqube’]
:sonarqube (Thread[Execution worker for ‘:’,5,main]) started.

Task :sonarqube
Caching disabled for task ‘:sonarqube’ because:
Build cache is disabled
Task ‘:sonarqube’ is not up-to-date because:
Task has not declared any outputs despite executing actions.
User cache: C:\Users\ukrbat.sonar\cache
Default locale: “en_GB”, source code encoding: “windows-1252” (analysis is platform dependent)
SonarScanner will require Java 11+ to run starting in SonarQube 8.x
Load global settings
Load global settings (done) | time=109ms
Server id: 587ABA1F-AW0cKYSUalO8nupKjkfP
User cache: C:\Users\ukrbat.sonar\cache
Load/download plugins
Load plugins index
Load plugins index (done) | time=53ms
Load/download plugins (done) | time=419ms
Loaded core extensions: developer-scanner
Process project properties
Execute project builders
Execute project builders (done) | time=7ms
Project key: ClassLibrary1
Base dir: C:\Users\ukrbat\Documents\Visual Studio 2017\Projects\ClassLibrary1
Working dir: C:\Users\ukrbat\Documents\Visual Studio 2017\Projects\ClassLibrary1\build\sonar
Load project settings for component key: ‘ClassLibrary1’
Load project settings for component key: ‘ClassLibrary1’ (done) | time=27ms
Load project branches
Load project branches (done) | time=23ms
Load project pull requests
Load project pull requests (done) | time=15ms
Load branch configuration
Load branch configuration (done) | time=1ms
Load quality profiles
Load quality profiles (done) | time=84ms
Load active rules
Load active rules (done) | time=1236ms
Indexing files…
Project configuration:

15 files indexed

Task :sonarqube
0 files ignored because of scm ignore settings
Quality profile for cs: Sonar way
------------- Run sensors on module TestProject
Load metrics repository
Load metrics repository (done) | time=23ms
Sensor C# Properties [csharp]
Property missing: ‘sonar.cs.analyzer.projectOutPaths’. No protobuf files will be loaded for this project.
No Roslyn issues report found for this project.
Sensor C# Properties [csharp] (done) | time=2ms
Sensor JavaXmlSensor [java]
Sensor JavaXmlSensor [java] (done) | time=2ms
Sensor HTML [web]
Sensor HTML [web] (done) | time=8ms
Sensor JaCoCo XML Report Importer [jacoco]
Sensor JaCoCo XML Report Importer [jacoco] (done) | time=5ms
Sensor C# [csharp]
Sensor C# [csharp] (done) | time=3ms
Sensor JavaSecuritySensor [security]
Reading type hierarchy from: C:\Users\ukrbat\Documents\Visual Studio 2017\Projects\ClassLibrary1\build\sonar\ucfg2\java
Read 0 type definitions
Reading UCFGs from: C:\Users\ukrbat\Documents\Visual Studio 2017\Projects\ClassLibrary1\build\sonar\ucfg2\java
No UCFGs have been included for analysis.
Sensor JavaSecuritySensor [security] (done) | time=9ms
Sensor CSharpSecuritySensor [security]
Reading type hierarchy from: C:\Users\ukrbat\Documents\Visual Studio 2017\Projects\ClassLibrary1\build\ucfg_cs2
Read 0 type definitions
Reading UCFGs from: C:\Users\ukrbat\Documents\Visual Studio 2017\Projects\ClassLibrary1\build\ucfg_cs2
No UCFGs have been included for analysis.
Sensor CSharpSecuritySensor [security] (done) | time=2ms
Sensor PhpSecuritySensor [security]
Reading type hierarchy from: C:\Users\ukrbat\Documents\Visual Studio 2017\Projects\ClassLibrary1\build\sonar\ucfg2\php
Read 0 type definitions
Reading UCFGs from: C:\Users\ukrbat\Documents\Visual Studio 2017\Projects\ClassLibrary1\build\sonar\ucfg2\php
No UCFGs have been included for analysis.
Sensor PhpSecuritySensor [security] (done) | time=0ms
------------- Run sensors on project
Sensor Zero Coverage Sensor
Sensor Zero Coverage Sensor (done) | time=6ms
Load project repositories
Load project repositories (done) | time=25ms
Calculating CPD for 0 files

CPD calculation finished

Task :sonarqube
Analysis report generated in 171ms, dir size=138 KB
Analysis report compressed in 49ms, zip size=20 KB
Analysis report generated in C:\Users\ukrbat\Documents\Visual Studio 2017\Projects\ClassLibrary1\build\sonar\scanner-report
Analysis report uploaded in 32ms
ANALYSIS SUCCESSFUL, you can browse http://tu-server-art:9000/dashboard?id=ClassLibrary1
Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
More about the report processing at http://tu-server-art:9000/api/ce/task?id=AW0_w3HMkhT_tdkk_1aM
Analysis total time: 11.561 s
:sonarqube (Thread[Execution worker for ‘:’,5,main]) completed. Took 14.968 secs.

BUILD SUCCESSFUL in 27s
1 actionable task: 1 executed

I’ve written a very simple app now which has this problem:

Anyone got any ideas?

hi @owen_battye

are you using the Sonar Scanner for MSBuild to analyze the project?

from what version of SonarQube have you upgraded? what was the previous version of SonarCSharp that you were using?

ah sorry, I said some of that above, but I’ve learnt some more about this now.

Im using SonarQube’s own gradle plugin:
gradle plugin: org.sonarqube version 2.6.2
I was using:
gradle plugin: org.sonarqube version 2.4.

we were using sonarqube server version 6.4, we’re now using 7.9.1

I suspect whats happening here is the the SQ gradle plugin:
https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-gradle/
doesnt support c#, but unlike the:
https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/
version, it doesnt make it clear it doesnt support c#. At least not to my reading of the docs…

but the
https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-gradle/
is giving me the errors:
Property missing: `sonar.cs.analyzer.projectOutPaths
which are explicitly called out in the generic SQ scanner docs, at the very bottom:
https://docs.sonarqube.org/latest/analysis/scan/sonarscanner/

so I guess, the gradle plugin is just calling the generic scanner.

so there isnt support for c# in SQ using gradle?

that’s correct, you need to use the Sonar Scanner for MSBuild to analyze the code.

damn it! thanks!

Could you make that more specific in the docs for the gradle plugin pls?

hi @owen_battye - just to make sure I understand: are you using Gradle for your C# projects?

The SonarScanner for Gradle docs specify

The SonarScanner for Gradle provides an easy way to start SonarQube analysis of a Gradle project.

Hey @Andrei_Epure

  1. Yep.

  2. Where does it say in:
    https://docs.sonarqube.org/latest/analysis/scan/sonarscanner-for-gradle/
    that it doesnt support c#?

Owen

It doesn’t, we’ll have to add that.