gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 14:30:16 25 4
gpt4 key购买 nike

我正在尝试使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com