SonarRunner 因缺少 FxCop 而失败

SonarRunner fails because of missing FxCop

我的 TFS 2013 构建失败并出现以下错误:

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".

我没有或不需要 FxCop 程序集。 FxCop 不再与 .NET 4.5 兼容。我使用 SonarQube 5.1.1 和 SonarRunner 2.4。我有 C++ 和 C# 的插件。 我如何 运行 没有 FxCop 的 SonarRunner?

FxCop 实际上兼容 Framework 4.5 及更高版本,但您需要获取 Visual Studio.

自带的代码分析位置

默认位置是:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop

所以让它工作的最简单方法是在您的构建服务器上安装 Visual Studio 的兼容版本,2013 的 Express 版本应该可以。或者您可以将自己的 Static Analysis Tools\FxCop 文件夹复制到您的构建服务器。

要禁用Sonar中的FxCop规则,我相信你可以设置:

sonar.fxcop.mode=disabled

并在 Sonar 的 C# 质量配置文件部分确保禁用所有 FxCop 相关规则。

从您的个人资料中删除 FxCop 规则(您可以通过在个人资料中执行 Repository=FxCop 搜索来找到它们)。然后 FxCop 将不会被调用,您的分析将起作用。