C# analysis ignored, why?

Hi

I’ve run locally using below commands and it works ok i.e. the reports are published to sonarqube server. Running on GCP pipeline using this community sonar scanner image (https://github.com/GoogleCloudPlatform/cloud-builders-community/tree/master/sonarqube) it ignores the C# files. Any idea what could be the problem?

dotnet "SonarScanner.MSBuild.dll" begin /k:"Web" /d:sonar.host.url="http://***/" /d:sonar.login="***"
dotnet build CAP.sln
dotnet "SonarScanner.MSBuild.dll" end /d:sonar.login="***"
Pulling image: gcr.io/projectone/sonar-scanner:latest
latest: Pulling from projectone/sonar-scanner
801bfaa63ef2: Pulling fs layer
f1707cbd5cc6: Pulling fs layer
27ac4aeeec04: Pulling fs layer
801bfaa63ef2: Verifying Checksum
801bfaa63ef2: Download complete
27ac4aeeec04: Verifying Checksum
27ac4aeeec04: Download complete
f1707cbd5cc6: Verifying Checksum
f1707cbd5cc6: Download complete
801bfaa63ef2: Pull complete
f1707cbd5cc6: Pull complete
27ac4aeeec04: Pull complete
Digest: sha256
Status: Downloaded newer image for gcr.io/projectone/sonar-scanner:latest
gcr.io/projectone/sonar-scanner:latest
START: Running sonar-scanner-cli on Thu Jan 14 15:29:32 UTC 2021
INFO: Scanner configuration file: /opt/sonar-scanner-3.2.0.1227-linux/conf/sonar-scanner.properties
INFO: Project root configuration file: NONE
INFO: SonarQube Scanner 3.2.0.1227
INFO: Java 11.0.9 Alpine (64-bit)
INFO: Linux 5.4.0-1029-gcp amd64
INFO: User cache: /root/.sonar/cache
INFO: SonarQube server 8.6.0
INFO: Default locale: "en_US", source code encoding: "UTF-8" (analysis is platform dependent)
INFO: Load global settings
INFO: Load global settings (done) | time=399ms
INFO: Server id: 12ABCD12-XYZwatkPbFh1xcAy_WRH
INFO: User cache: /root/.sonar/cache
INFO: Load/download plugins
INFO: Load plugins index
INFO: Load plugins index (done) | time=215ms
INFO: Load/download plugins (done) | time=8835ms
INFO: Process project properties
INFO: Process project properties (done) | time=25ms
INFO: Execute project builders
INFO: Execute project builders (done) | time=3ms
INFO: Project key: Web
INFO: Base dir: /workspace
INFO: Working dir: /workspace/.scannerwork
INFO: Load project settings for component key: 'Web'
INFO: Load quality profiles
INFO: Load quality profiles (done) | time=441ms
INFO: Load active rules
INFO: Load active rules (done) | time=4621ms
INFO: Indexing files...
INFO: Project configuration:
INFO:   Excluded sources: CAP.Test/*.html
INFO: Load project repositories
INFO: Load project repositories (done) | time=142ms
INFO: 408 files indexed
INFO: 4 files ignored because of inclusion/exclusion patterns
INFO: 23 files ignored because of scm ignore settings
INFO: Quality profile for cs: Sonar way
INFO: Quality profile for css: Sonar way
INFO: Quality profile for js: Sonar way
INFO: Quality profile for web: Sonar way
INFO: Quality profile for xml: Sonar way
INFO: ------------- Run sensors on module Web
INFO: Load metrics repository
INFO: Load metrics repository (done) | time=194ms
INFO: Sensor CSS Metrics [cssfamily]
INFO: Sensor CSS Metrics [cssfamily] (done) | time=992ms
INFO: Sensor CSS Rules [cssfamily]
ERROR: CSS rules were not executed. Error when running: 'node -v'. Is Node.js available during analysis?
org.sonarsource.nodejs.NodeCommandException: Error when running: 'node -v'. Is Node.js available during analysis?
	at org.sonarsource.nodejs.NodeCommand.start(NodeCommand.java:80)
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.getVersion(NodeCommandBuilderImpl.java:181)
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.checkNodeCompatibility(NodeCommandBuilderImpl.java:159)
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.build(NodeCommandBuilderImpl.java:134)
	at org.sonar.css.plugin.server.CssAnalyzerBridgeServer.initNodeCommand(CssAnalyzerBridgeServer.java:153)
	at org.sonar.css.plugin.server.CssAnalyzerBridgeServer.startServer(CssAnalyzerBridgeServer.java:104)
	at org.sonar.css.plugin.server.CssAnalyzerBridgeServer.startServerLazily(CssAnalyzerBridgeServer.java:173)
	at org.sonar.css.plugin.CssRuleSensor.execute(CssRuleSensor.java:99)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:393)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:389)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:144)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at com.sun.proxy.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:171)
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:128)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.io.IOException: Cannot run program "node": error=2, No such file or directory
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
	at org.sonarsource.nodejs.NodeCommand$ProcessWrapperImpl.start(NodeCommand.java:159)
	at org.sonarsource.nodejs.NodeCommand.start(NodeCommand.java:76)
	... 37 common frames omitted
Caused by: java.io.IOException: error=2, No such file or directory
	at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
	at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:340)
	at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:271)
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
	... 40 common frames omitted

INFO: Sensor CSS Rules [cssfamily] (done) | time=1249ms
INFO: Sensor JaCoCo XML Report Importer [jacoco]
INFO: 'sonar.coverage.jacoco.xmlReportPaths' is not defined. Using default locations: target/site/jacoco/jacoco.xml,target/site/jacoco-it/jacoco.xml,build/reports/jacoco/test/jacocoTestReport.xml
INFO: No report imported, no coverage information will be imported by JaCoCo XML Report Importer
INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=17ms
INFO: Sensor JavaScript analysis [javascript]
ERROR: Error when running: 'node -v'. Is Node.js available during analysis?
org.sonarsource.nodejs.NodeCommandException: Error when running: 'node -v'. Is Node.js available during analysis?
	at org.sonarsource.nodejs.NodeCommand.start(NodeCommand.java:81)
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.getVersion(NodeCommandBuilderImpl.java:181)
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.checkNodeCompatibility(NodeCommandBuilderImpl.java:159)
	at org.sonarsource.nodejs.NodeCommandBuilderImpl.build(NodeCommandBuilderImpl.java:134)
	at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.initNodeCommand(EslintBridgeServerImpl.java:165)
	at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.startServer(EslintBridgeServerImpl.java:114)
	at org.sonar.plugins.javascript.eslint.EslintBridgeServerImpl.startServerLazily(EslintBridgeServerImpl.java:182)
	at org.sonar.plugins.javascript.eslint.AbstractEslintSensor.startBridge(AbstractEslintSensor.java:145)
	at org.sonar.plugins.javascript.eslint.AbstractEslintSensor.execute(AbstractEslintSensor.java:119)
	at org.sonar.plugins.javascript.eslint.JavaScriptEslintBasedSensor.execute(JavaScriptEslintBasedSensor.java:51)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:393)
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:389)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:144)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
	at com.sun.proxy.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:171)
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:128)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:111)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
	at org.sonarsource.scanner.cli.Main.main(Main.java:61)
Caused by: java.io.IOException: Cannot run program "node": error=2, No such file or directory
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1071)
	at org.sonarsource.nodejs.NodeCommand$ProcessWrapperImpl.start(NodeCommand.java:162)
	at org.sonarsource.nodejs.NodeCommand.start(NodeCommand.java:77)
	... 39 common frames omitted
Caused by: java.io.IOException: error=2, No such file or directory
	at java.base/java.lang.ProcessImpl.forkAndExec(Native Method)
	at java.base/java.lang.ProcessImpl.<init>(ProcessImpl.java:340)
	at java.base/java.lang.ProcessImpl.start(ProcessImpl.java:271)
	at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1107)
	... 42 common frames omitted

INFO: Sensor JavaScript analysis [javascript] (done) | time=1806ms
INFO: Sensor C# Properties [csharp]
INFO: Sensor C# Properties [csharp] (done) | time=1ms
INFO: Sensor JavaXmlSensor [java]
INFO: 1 source files to be analyzed
INFO: 1/1 source files have been analyzed
INFO: Sensor JavaXmlSensor [java] (done) | time=341ms
INFO: Sensor HTML [web]
INFO: Sensor HTML [web] (done) | time=1417ms
INFO: Sensor XML Sensor [xml]
INFO: 1 source files to be analyzed
INFO: 1/1 source files have been analyzed
INFO: Sensor XML Sensor [xml] (done) | time=278ms
INFO: Sensor VB.NET Properties [vbnet]
INFO: Sensor VB.NET Properties [vbnet] (done) | time=1ms
INFO: ------------- Run sensors on project
INFO: Sensor C# [csharp]
WARN: No protobuf reports found. The C# files will not have highlighting and metrics.
WARN: No Roslyn issue reports were found. The C# files have not been analyzed.
WARN: Your project contains C# files which cannot be analyzed with the scanner you are using. To analyze C# or VB.NET, you must use the Scanner for MSBuild 4.x, see https://redirect.sonarsource.com/doc/install-configure-scanner-msbuild.html
INFO: Sensor C# [csharp] (done) | time=2ms
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=11ms
INFO: SCM Publisher SCM provider for this project is: git
INFO: SCM Publisher 297 source files to be analyzed
WARN: Shallow clone detected, no blame information will be provided. You can convert to non-shallow with 'git fetch --unshallow'.
INFO: SCM Publisher 0/297 source files have been analyzed (done) | time=5ms
WARN: Missing blame information for the following files:
WARN:   * CAP.Test/PageObjects/IaoApproveObjects.cs
WARN:   * CAP/Views/_ViewStart.cshtml
WARN:   * CAP/Startup.cs
WARN:   * CAP/Models/CbiAnnotateViewModel.cs
WARN:   * CAP/Views/Procurement/Other.cshtml
WARN:   * CAP/Models/ApplicantCrmViewModel.cs
WARN:   * CAP/Helper/ContractUtility.cs
WARN:   * CAP/wwwroot/lib/bootstrap/dist/css/bootstrap-reboot.css
WARN:   * CAP/Models/ExtendViewModel.cs
WARN:   * CAP.Test/PageObjects/ProcurementChoiceObjects.cs
WARN:   * CAP/Views/Static/CslLearning.cshtml
WARN:   * CAP/wwwroot/lib/bootstrap/dist/js/bootstrap.js
WARN:   * CAP.Test/PageOps.cs
WARN:   * CAP/Views/Procurement/Training.cshtml
WARN:   * CAP/Views/ApplicantCrm/CrmDetails.cshtml
WARN:   * CAP/Models/ProcurementViewModels/ConsultancyProcurementViewModel.cs
WARN:   * CAP/Views/Shared/_ProcurementTimeOutModal.cshtml
WARN:   * CAP/Services/CapUser.cs
WARN:   * CAP/Views/IaoInformation/Index.cshtml
WARN:   * CAP/wwwroot/lib/bootstrap/dist/css/bootstrap-theme.css
WARN:   * CAP/ViewComponents/ReturnToCrmDashboardViewComponent.cs
WARN:   * CAP/Models/LegacyContractDetailsViewModel.cs
WARN:   * CAP/ViewComponents/ExistingContractErrorSummaryViewComponent.cs
WARN:   * CAP.Test/PageObjects/CbiAwardObjects.cs
WARN:   * CAP/ViewComponents/ExtendTableViewComponent.cs
WARN:   * CAP/Views/Stats/Index.cshtml
WARN: This may lead to missing/broken features in SonarQube
INFO: CPD Executor 9 files had no CPD blocks
INFO: CPD Executor Calculating CPD for 95 files
INFO: CPD Executor CPD calculation finished (done) | time=94ms
INFO: Analysis report generated in 314ms, dir size=2 MB
INFO: Analysis report compressed in 595ms, zip size=716 KB
INFO: Analysis report uploaded in 1632ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://****/dashboard?id=Web
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://****/api/ce/task?id=AXcBhKdoYlEf4qHyYpHT
INFO: Analysis total time: 20.972 s
INFO: ------------------------------------------------------------------------
INFO: EXECUTION SUCCESS
INFO: ------------------------------------------------------------------------
INFO: Total time: 35.081s
INFO: Final Memory: 13M/56M
INFO: ------------------------------------------------------------------------
END: Running sonar-scanner-cli on Thu Jan 14 15:30:07 UTC 2021

Also - I’ve installed nodejs on sonarqube server but still getting that error message…‘Error when running: ‘node -v’. Is Node.js available during analysis?’ How do I resolve that?

Thanks

Hello
It seems that the problem comes from the old version of the Scanner for MSBuild included in this image:

WARN: Your project contains C# files which cannot be analyzed with the scanner you are using. To analyze C# or VB.NET, you must use the Scanner for MSBuild 4.x, see https://redirect.sonarsource.com/doc/install-configure-scanner-msbuild.html

Please try using the latest version of SonarScanner for .NET coming from SonarSource.

Best,

Hi Michal

Is it just the Scanner that needs to be upgraded or the image requires dotnet sdk installed too?

Would the SDK’s for all the language exists on sonarqube server as part of sonarqube installations and scanner would just send off the signal to server for analysis? is that how it works or the scanner will need the SDK too?

Thanks

Thanks