SonarScanner for MSBuild produces error /Za

sonarcfamily
(Janet Dermer) #1

Sonar Server - Version 6.7.2 (build 37468)
Sonar build-wrapper, version 6.1 (win-x86-64)
SonarScanner for MSBuild version 4.6.0.1930 - .NET Fwk 4.6
Java Version 1.8.0_201

I’m trying to get a Sonar analysis using an updated version of the Sonar C/C++ plugin. I didn’t have any problems running Sonar with the old plugin, but I can’t get it to work now. I’ve tried running it manually from the command line and using the Jenkins plugin, but I always get a /Za error. Here is what I’m running:

SonarScanner.MSBuild.exe begin /k:TestRepo /n:TestRepo /v:1.0 /d:sonar.host.url=<sonar_server> /d:sonar.cfamily.build-wrapper-output=bw_output /d:sonar.sources=test/src,test/include /d:sonar.exclusions=**/Weather/.pb. /d:sonar.verbose=true

build-wrapper-win-x86-64.exe --out-dir bw_output msbuild.exe test.sln /t:Rebuild /p:Configuration=Release /p:Platform=x64

SonarScanner.MSBuild.exe end
:
:
:
13:27:22 13:27:21.912 INFO: ------------------------------------------------------------------------
13:27:21.913 INFO: EXECUTION FAILURE
13:27:21.913 INFO: ------------------------------------------------------------------------
13:27:21.914 INFO: Total time: 32.555s
13:27:22.075 INFO: Final Memory: 32M/649M
13:27:22.075 INFO: ------------------------------------------------------------------------
13:27:22.076 ERROR: Error during SonarQube Scanner execution
java.lang.UnsupportedOperationException: /Za
at com.sonar.cpp.analyzer.MsvcDriver.onCapture(MsvcDriver.java:122)
at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:262)
at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:198)
at org.sonar.scanner.sensor.SensorWrapper.analyse(SensorWrapper.java:53)
at org.sonar.scanner.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:88)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:82)
at org.sonar.scanner.phases.SensorsExecutor.execute(SensorsExecutor.java:73)
at org.sonar.scanner.phases.AbstractPhaseExecutor.execute(AbstractPhaseExecutor.java:88)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:180)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:288)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:283)
at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:261)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
at org.sonar.scanner.task.ScanTask.execute(ScanTask.java:48)
at org.sonar.scanner.task.TaskContainer.doAfterStart(TaskContainer.java:84)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:135)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:121)
at org.sonar.scanner.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:121)
at org.sonar.batch.bootstrapper.Batch.doExecuteTask(Batch.java:116)
at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:71)
at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
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:185)
at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:137)
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)
Process returned exit code 1
The SonarQube Scanner did not complete successfully
13:27:22.205 Post-processing failed. Exit code: 1

I’ve tried using older versions of Java and the SonarScanner, but I get a similar /Za error and I can’t find any references to what that error means.

SonarScanner.MSBuild.exe end
:
:
:
10:07:22.567 INFO: EXECUTION FAILURE
10:07:22.567 INFO: ------------------------------------------------------------------------
10:07:22.567 INFO: Total time: 38.131s
10:07:22.716 INFO: Final Memory: 28M/538M
10:07:22.716 INFO: ------------------------------------------------------------------------
10:07:22.716 ERROR: Error during SonarQube Scanner execution
10:07:22.717 ERROR: /Za
10:07:22.717 ERROR:
Process returned exit code 1
The SonarQube Scanner did not complete successfully
10:07:22.837 Creating a summary markdown file…
10:07:22.839 Post-processing failed. Exit code: 1
WARN: Unable to locate ‘report-task.txt’ in the workspace. Did the SonarScanner succedeed?
ERROR: Execution of SonarScanner for MSBuild failed (exit code 1)

(Massimo Paladin) #2

Hi @jdermer1,

thank you for your report, indeed we didn’t add support for /Za option, I created a ticket to add support for it: https://jira.sonarsource.com/browse/CPP-2180.

(Janet Dermer) #3

Hi Massimo, Thank you for opening the ticket. Do you know when it will be fixed?

(Massimo Paladin) #4

Hi @jdermer1,

it is going to be fixed with 6.2 version of the analyzer, which we are planning for end of April and should be shipped with SonarQube 7.8.