c# - 如何使用 SonarQube 的 C# 插件设置 FxCop 安装路径

标签 c# sonarqube sonar-runner

我正在尝试使用 SonarQube C# 插件分析 .NET C# 项目。 从 C# 插件 3.0 开始,FxCop 会自动执行,即使在 sonar-project.properties 中有“sonar.fxcop.mode=skip”,所以我将 FxCop 安装到以下目录。

C:\Program Files (x86)\Microsoft FxCop 1.35

当我从 Jenkins 的 Sonar 插件运行 SonarQube Runner 时,出现以下错误。

ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: The property "sonar.cs.fxcop.assembly" must be set.
ERROR: 
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.
Build step 'Invoke Standalone Sonar Analysis' marked build as failure
Finished: FAILUR

我在 SonarQube 上启用了 Visual Studio Bootstrapper,然后再次运行 SonarQube Runner,然后出现以下错误。

ERROR: Error during Sonar runner execution
ERROR: Unable to execute Sonar
ERROR: Caused by: java.io.IOException: Cannot run program "C:/Program Files (x86)/Microsoft Visual Studio 12.0/Team Tools/Static Analysis Tools/FxCop/FxCopCmd.exe": CreateProcess error=2, ?w?????t?@?
ERROR: Caused by: Cannot run program "C:/Program Files (x86)/Microsoft Visual Studio 12.0/Team Tools/Static Analysis Tools/FxCop/FxCopCmd.exe": CreateProcess error=2, ?w?????t?@?
ERROR: Caused by: CreateProcess error=2, ?w?????t?@?
ERROR: 
ERROR: To see the full stack trace of the errors, re-run SonarQube Runner with the -e switch.
ERROR: Re-run SonarQube Runner using the -X switch to enable full debug logging.

我将“sonar.fxcop.installDirector=C:/Program Files (x86)/Microsoft FxCop 1.35”添加到 sonar-project.properties,然后再次运行 SonarQube Runner,但出现了同样的错误。

我想如果 Visual Studio Bootstrapper 被禁用并且 sonar-project.properties 正确指定“sonar.cs.fxcop.assembly”和“sonar.fxcop.installDirector”,它工作正常,但我不想指定很多属性在 sonar-project.properties 中。

如何通过启用 Visual Studio Bootstrapper 设置 FxCop 执行路径?

环境:

  • SonarQube4.2
  • SonarQube 的 C# 插件 3.0
  • SonarQube runner 2.4

Sonar 项目.properties

sonar.projectKey=xxxxx
sonar.projectVersion=1.0
sonar.projectName=Project Name

sonar.language=cs
sonar.dotnet.key.generation.strategy=safe
sonar.sourceEncoding=UTF-8

# This property is set because it is required by the SonarQube Runner.
# But it is not taken into account because the location of the source
# code is retrieved from the .sln and .csproj files.
sonar.sources=.
sonar.fxcop.mode=skip
sonar.gendarme.mode=skip
sonar.gallio.mode=skip
sonar.ndeps.mode=skip
sonar.stylecop.mode=skip
sonar.fxcop.installDirector=C:/Program Files (x86)/Microsoft FxCop 1.35

问候

最佳答案

我找到了这个问题的解决方案,以管理身份登录 sonar qube 然后转到设置,在常规设置下找到类别,选择 C# 然后单击代码分析/FxCop 选项卡,然后找到“Path to FxCopCMD.Exe "并按照示例中的建议添加 FXCopCMD.exe 的完整路径

click on this to see image and process

关于c# - 如何使用 SonarQube 的 C# 插件设置 FxCop 安装路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23822527/

相关文章:

unit-testing - Sonarqube 忽略测试执行数据

c# - SSDT 数据库项目与 SonarQube 的代码分析集成

unit-testing - SonarQube单元测试,不含二进制文件

sonarqube - 为项目中的所有 java 文件禁用特定的 sonarqube 规则

c# - 为什么我的 Storboard 不显示?

c# - 如何自动化 MVC IIS 的开发机器

c# - 仅使用 TcpClient 和 StreamWriter/StreamReader 读取 POP3 服务器

maven - SONAR 使用 mvn Sonar :sonar? 将 cobertura.ser 覆盖率报告导入到 Sonar 服务器

java - 计算方法复杂度的原理是什么?

c# - 在我自己的 "UITableViewController"中使用默认实现使方法可选