【问题标题】:FxCop must be installed errorFxCop 必须安装错误
【发布时间】:2016-05-11 15:25:47
【问题描述】:

我正在使用以下配置在构建服务器上构建和分析示例 C# 项目:

  • 詹金斯 1.630;
  • SonarQube 5.3 包含所有更新;
  • FxCop 10.0

我在 Jenkins Job 中放了以下步骤:

  • 用于 MSBuild 的 SonarQube 扫描仪 - 开始分析
  • 使用 MSBuild (MSBuild 14) 构建 Visual Studio 项目或解决方案
  • 用于 MSBuild 的 SonarQube 扫描仪 - 结束分析

如果默认 C# 配置文件中没有 FxCop 规则,则一切正常:项目在编译时没有警告,然后进行分析。如果至少有一个 FxCop,则构建失败:

V:\JenkinsWkFolder\Test\.sonarqube\bin\targets\SonarQube.Integration.targets(402,5): error : FxCop must be installed when some of its rules are enabled in the SonarQube quality profile. FxCop is included as part of Visual Studio. [V:\JenkinsWkFolder\Test\CSharpConsoleApp\CSharpConsoleApp.csproj]

Done Building Project "V:\JenkinsWkFolder\Test\CSharpConsoleApp\CSharpConsoleApp.csproj" (Rebuild target(s)) -- FAILED.
Done Building Project "V:\JenkinsWkFolder\Test\CITest.sln" (rebuild target(s)) -- FAILED.

Build FAILED.

"V:\JenkinsWkFolder\Test\CITest.sln" (rebuild target) (1) ->
"V:\JenkinsWkFolder\Test\CSharpConsoleApp\CSharpConsoleApp.csproj" (Rebuild target) (2) ->
(FailIfFxCopNotInstalled target) -> 
  V:\JenkinsWkFolder\Test\.sonarqube\bin\targets\SonarQube.Integration.targets(402,5): error : FxCop must be installed when some of its rules are enabled in the SonarQube quality profile. FxCop is included as part of Visual Studio. [V:\JenkinsWkFolder\Test\CSharpConsoleApp\CSharpConsoleApp.csproj]

    0 Warning(s)
    1 Error(s)

FxCop 安装在构建服务器上,而 Visual Studio 没有。 MsBuildSonarRunner 在哪里寻找 FxCop 可执行文件?

我不知道您是否需要其他信息,请随时询问更多详细信息。 提前致谢。 最好的问候,

马里奥。

【问题讨论】:

  • FXcop 在路径中吗?
  • 感谢您的回复,@sam-holder。我在步骤 Build Environment 中设置了 FxCop 路径 / 将环境变量注入构建过程 Properties Content: PATH=C:\Program Files (x86)\Microsoft Fxcop 10.0;C:\....SonarQube Scanner for MSBuild - Begin Analysis 中是否有除 Additional arguments: /d:sonar.verbose=true 之外的任何更深层次的调试选项?
  • 我从命令行运行 msbuild,遇到了同样的错误。以最大详细度(诊断)执行它,出现可疑错误:由于错误条件,已跳过目标“SetFxCopAnalysisResult”; ( $(SonarQubeRunMSCodeAnalysis) == 'true' ) 被评估为 ( == 'true' ) 在我看来,问题是来自 msbuild 规则集的错误,与 fxcop 安装无关。.

标签: jenkins sonarqube fxcop sonarqube-msbuild-runner


【解决方案1】:

SonarQube 仅支持 MSBuild 14 和 FxCop 14(MSBuild 12/FxCop 12 将很快被弃用)。

很遗憾,在将 MSBuild 工具与 VisualStudio 分开安装时,FxCop 未与 MSBuild 一起安装。要获得 FxCop 14,您必须安装 Visual Studio 2015(FxCop 10 是最后一个可以独立安装的版本)。 在互联网上,您可以找到在没有 VS2015 的情况下手动安装 FxCop 14 的方法,但这不是 Microsoft 官方程序。

【讨论】:

  • 亲爱的奥利维尔,感谢您的回复。我很难在没有 Visual Studio 的情况下安装 FxCop(我想让构建服务器尽可能轻),但我不得不面对奇怪的错误,还需要手动修改所有 .csproj 以指向 fxcop 安装。然后,我决定摆脱 fxcop 规则并用 sonar c# 或 resharper 规则替换它们。再次感谢。
猜你喜欢
  • 1970-01-01
  • 2021-09-08
  • 2012-11-12
  • 1970-01-01
  • 1970-01-01
  • 2021-12-17
  • 2021-06-23
相关资源
最近更新 更多