【问题标题】:The property "sonar.cs.fxcop.assembly" must be set and the project must have been built to execute FxCop rules必须设置属性“sonar.cs.fxcop.assembly”并且必须已构建项目以执行 FxCop 规则
【发布时间】:2016-03-19 04:05:45
【问题描述】:

我正在使用 SonarQube 5.1.2 与 C# Plugin 4.2 和由 Jenkins 执行的 MSBuild Sonar Runner 1.0.1。

运行分析时出现以下错误:

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

我看到另一个类似问题的踏板,他们的解决方案是从路径中删除单词 test。我的路径没有“测试”这个词。

不知道下一步该做什么。

【问题讨论】:

  • 你能告诉你在 Jenkins 中启动 SonarQube 分析的步骤吗?
  • 1. D:\MSBuild.SonarQube.Runner-1.0.2\MSBuild.SonarQube.Runner.exe 开始 /k:"foo" /n:"foo" /v:"1.0" /d:sonar.resharper.cs.reportPath= "D:\TestResults\resharper.xml" /d:sonar.resharper.solutionFile="Solutions\foo.sln"
  • 2.我使用 msbuild 插件来构建解决方案。我为配置和平台传入 msbuild 属性。
  • 3. D:\JetBrains.ReSharper.CommandLineTools\inspectcode.exe /output="D:\TestResults\resharper.xml" "Solutions\foo.sln"
  • 4. D:\MSBuild.SonarQube.Runner-1.0.2\MSBuild.SonarQube.Runner.exe 结束

标签: sonarqube sonarqube-msbuild-runner


【解决方案1】:

原来在我的 Jenkins 代理上我没有任何代码分析工具。所以在 MSbuild 步骤中,没有通过 fxcop 运行代码分析。

我安装了 Visual Studio 2013 并解决了我的问题。

【讨论】:

  • 谢谢,这是很好的反馈。在这种情况下,我创建了一张票来改进错误报告:jira.sonarsource.com/browse/SONARMSBRU-161
  • 嘿 Dinesh,还有一点要添加到错误报告中。在我的一个解决方案中,我有 C# 和 VB.Net 项目。我没有为 VB 插件付费。所以我的分析失败了,在我的 VB 项目中出现了上面提到的相同错误。我必须从 msbuild 和 sonar runner end 命令之间的 .out 文件夹中删除这些项目的输出,才能成功进行分析。
  • 如果您没有付费,您应该卸载 VB.NET 插件。
  • 对不起!看完我的评论后,我意识到这是非常误导的。我要说的是我们没有安装插件,因为我们没有商业许可证。但是,由于我的解决方案中包含 VB 代码,并且由于我们没有插件,因此在遇到 vb 项目时分析失败(原始帖子中的错误相同)。
【解决方案2】:

您应该安装 Visual Studio,因为 FxCop 附带它(例如 C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop),但如果您不这样做,这些命令将不起作用使用“Visual Studio 2013 或更高版本的开发人员命令提示符”。 (http://docs.sonarqube.org/display/SONAR/Analyzing+with+SonarQube+Scanner+for+MSBuild)。

【讨论】:

  • 谢谢!正如我上面提到的,我确实安装了 Visual Studio 和代码分析工具。但是我正在使用 Jenkins 运行命令,并且能够直接从正常的命令提示符运行它们。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-17
  • 1970-01-01
  • 2016-05-09
  • 1970-01-01
  • 2021-12-03
  • 1970-01-01
相关资源
最近更新 更多