0

I am using SonarQube 5.1.2 with C# Plugin 4.2 and MSBuild Sonar Runner 1.0.1 being executed by Jenkins.

I am getting the following error when running the analysis:

ERROR: Error during Sonar runner execution
org.sonar.runner.impl.RunnerException: Unable to execute Sonar
    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:91)
    at org.sonar.runner.impl.BatchLauncher$1.run(BatchLauncher.java:75)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.sonar.runner.impl.BatchLauncher.doExecute(BatchLauncher.java:69)
    at org.sonar.runner.impl.BatchLauncher.execute(BatchLauncher.java:50)
    at org.sonar.runner.api.EmbeddedRunner.doExecute(EmbeddedRunner.java:102)
    at org.sonar.runner.api.Runner.execute(Runner.java:100)
    at org.sonar.runner.Main.executeTask(Main.java:70)
    at org.sonar.runner.Main.execute(Main.java:59)
    at org.sonar.runner.Main.main(Main.java:53)
Caused by: java.lang.IllegalArgumentException: The property "sonar.cs.fxcop.assembly" must be set and the project must have been built to execute FxCop rules. This property can be automatically set by the Analysis Bootstrapper for Visual Studio Projects plugin, see: http://docs.codehaus.org/x/TAA1Dg.If you wish to skip the analysis of not built projects, set the property "sonar.visualstudio.skipIfNotBuilt".
    at org.sonar.plugins.fxcop.FxCopConfiguration.checkMandatoryProperties(FxCopConfiguration.java:105)
    at org.sonar.plugins.fxcop.FxCopConfiguration.checkProperties(FxCopConfiguration.java:96)
    at org.sonar.plugins.fxcop.FxCopSensor.analyse(FxCopSensor.java:92)
    at org.sonar.plugins.fxcop.FxCopSensor.analyse(FxCopSensor.java:87)
    at org.sonar.batch.phases.SensorsExecutor.executeSensor(SensorsExecutor.java:59)
    at org.sonar.batch.phases.SensorsExecutor.execute(SensorsExecutor.java:51)
    at org.sonar.batch.phases.DatabaseModePhaseExecutor.execute(DatabaseModePhaseExecutor.java:120)
    at org.sonar.batch.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:264)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.scan.ProjectScanContainer.scan(ProjectScanContainer.java:235)
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:230)
    at org.sonar.batch.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:228)
    at org.sonar.batch.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:220)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.scan.ScanTask.scan(ScanTask.java:57)
    at org.sonar.batch.scan.ScanTask.execute(ScanTask.java:45)
    at org.sonar.batch.bootstrap.TaskContainer.doAfterStart(TaskContainer.java:135)
    at org.sonar.api.platform.ComponentContainer.startComponents(ComponentContainer.java:92)
    at org.sonar.api.platform.ComponentContainer.execute(ComponentContainer.java:77)
    at org.sonar.batch.bootstrap.GlobalContainer.executeTask(GlobalContainer.java:158)
    at org.sonar.batch.bootstrapper.Batch.executeTask(Batch.java:95)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
    at org.sonar.runner.batch.IsolatedLauncher.execute(IsolatedLauncher.java:48)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.sonar.runner.impl.BatchLauncher$1.delegateExecution(BatchLauncher.java:87)
    ... 9 more

I saw another tread with a similar issue, their resolution was to remove the word test from the path. My path does not have the word "test".

Not sure what to do next.

Pascal Berger
  • 4,262
  • 2
  • 30
  • 54
  • 1
    can you tell the steps that you have in Jenkins to launch the SonarQube analysis? – Dinesh Bolkensteyn Oct 27 '15 at 07:51
  • 1. D:\MSBuild.SonarQube.Runner-1.0.2\MSBuild.SonarQube.Runner.exe begin /k:"foo" /n:"foo" /v:"1.0" /d:sonar.resharper.cs.reportPath="D:\TestResults\resharper.xml" /d:sonar.resharper.solutionFile="Solutions\foo.sln" – Amit Sheth Nov 06 '15 at 20:53
  • 2. I use the msbuild plugin to build the solution. I pass in msbuild properties for configuration and platform. – Amit Sheth Nov 06 '15 at 20:54
  • 3. D:\JetBrains.ReSharper.CommandLineTools\inspectcode.exe /output="D:\TestResults\resharper.xml" "Solutions\foo.sln" – Amit Sheth Nov 06 '15 at 20:55
  • 4. D:\MSBuild.SonarQube.Runner-1.0.2\MSBuild.SonarQube.Runner.exe end – Amit Sheth Nov 06 '15 at 20:55

2 Answers2

0

Turns out on my Jenkins agent I didn't have any code analysis tools. So during the MSbuild step, no code analysis was running via fxcop.

I installed visual studio 2013 and that resolved my issue.

  • Thank you, that is good feedback. I've created a ticket to improve the error reporting in that case: https://jira.sonarsource.com/browse/SONARMSBRU-161 – Dinesh Bolkensteyn Nov 09 '15 at 09:34
  • Hey Dinesh, Another point to add to the error reporting. In one of my solutions I have C# and VB.Net projects. I did not pay for the VB plugin. So my analysis fails with the same error mentioned above on my VB projects. I have to delete the output of those projects from my .out folder in between the msbuild and sonar runner end command in order to get a successful analysis. – Amit Sheth Nov 25 '15 at 20:55
  • You should uninstall the VB.NET plugin if you did not pay for it. – Dinesh Bolkensteyn Nov 30 '15 at 09:49
  • Sorry! After reading my comment I realized it was very misleading. What I ment to say is that we do not have the plugin installed, since we do not have the commercial license. However since my solution has VB code in it, and since we do not have the plugin, the analysis fails when it hits the vb projects (with the same error in original post). – Amit Sheth Dec 02 '15 at 17:34
0

You should install Visual Studio because FxCop comes with it (e.g. C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop) but the commands won't work if you don't use a "Developer Command Prompt for Visual Studio 2013 or higher". (http://docs.sonarqube.org/display/SONAR/Analyzing+with+SonarQube+Scanner+for+MSBuild).

Jhack
  • 510
  • 1
  • 6
  • 20
  • Thanks! As I mentioned above, I did install visual studio and the code analysis tools. However I am using Jenkins to run the commands and was able to run them directly from normal command prompt. – Amit Sheth Nov 25 '15 at 20:51