如何在构建服务器上运行 .NET 4 代码分析

发布于 2024-09-06 02:58:04 字数 852 浏览 2 评论 0原文

在带有 .NET 4 SDK 但没有 Visual Studio 2010 的 Windows Server 2003 R2 上,我尝试构建 Visual Studio 2010 解决方案,

msbuild MySolution.sln /p:RunCodeAnalysis=true

但失败了。

在这样的环境中运行代码分析需要什么?


我收到此错误消息:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(129,9): error MSB6003: 
The specified task executable "FxCopCmd.exe" could not be run. 
Could not load file or assembly 
'Microsoft.VisualStudio.CodeAnalysis.Sdk, Version=10.0.0.0, Culture=neutral, PublicKeyToken= b03f5f7f11d50a3a' 
or one of its dependencies. 
The system cannot find the file specified.

我已经从 SDK 安装了 FxCop,但不幸的是,我将变量 FxCopDir 指向 FxCopCmd.exe 的安装位置,并将此注册表项设置为该位置:

HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\10.0\Setup\EDev@FxCopDir

On a Windows Server 2003 R2 with .NET 4 SDK but without Visual Studio 2010, I have tried building a Visual Studio 2010 solution with

msbuild MySolution.sln /p:RunCodeAnalysis=true

but that fails.

What is required to run code analysis on such an environment?


I get this error message:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\CodeAnalysis\Microsoft.CodeAnalysis.targets(129,9): error MSB6003: 
The specified task executable "FxCopCmd.exe" could not be run. 
Could not load file or assembly 
'Microsoft.VisualStudio.CodeAnalysis.Sdk, Version=10.0.0.0, Culture=neutral, PublicKeyToken= b03f5f7f11d50a3a' 
or one of its dependencies. 
The system cannot find the file specified.

I have installed FxCop from the SDK and without luck pointed the variable FxCopDir to the installed location of FxCopCmd.exe, and also setting this registry entry to that location:

HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\10.0\Setup\EDev@FxCopDir

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

素手挽清风 2024-09-13 02:58:04

我在 MSBuild 服务器上遇到了同样的问题,并通过以下方式修复了该问题:

  • 安装 Windows SDK 7.1
  • FxCopDirStanDir 中设置注册表项>HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\10.0\Setup\EDev(在 Win32 中)。

然后,我将以下内容从开发 PC 复制到构建服务器上的 FxCop 文件夹:

  • 文件夹 Rule Sets(默认安装目标位于:C:\Program文件 (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\FxCop)
  • Microsoft.VisualStudio.CodeAnalysis.Sdk.dll
  • Microsoft.VisualStudio.CodeAnalysis.Phoenix.dll >
  • phx.dll

在安装了 Visual Studio 的开发 PC 上搜索它们以找到它们。

然后使用 .NET 4.0 版本的 gacutil.exeMicrosoft.VisualStudio.CodeAnalysis.Sdk.dll 安装到 GAC。

然后,您应该能够将代码分析作为 MSBuild 构建的一部分运行并使其正常工作。

I had the same problem on my MSBuild server and fixed it by:

  • Installing Windows SDK 7.1
  • Setting up the registry keys FxCopDir and StanDir in HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\10.0\Setup\EDev (in Win32).

I then copied over from the dev PC, to the FxCop folder on the build server, the following:

  • The folder Rule Sets (default installation target is here: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Team Tools\Static Analysis Tools\FxCop)
  • Microsoft.VisualStudio.CodeAnalysis.Sdk.dll
  • Microsoft.VisualStudio.CodeAnalysis.Phoenix.dll
  • phx.dll

Do a search for them on your dev PC with Visual Studio installed to locate them.

Then use the .NET 4.0 version of gacutil.exe to install Microsoft.VisualStudio.CodeAnalysis.Sdk.dll to the GAC.

You should then be able to run code analysis as part of an MSBuild build and have it work properly.

街角迷惘 2024-09-13 02:58:04

FxCop 的替代方法是使用 NDepend 工具,该工具让您可以通过 C# LINQ 查询(即 CQLinq)编写代码规则)免责声明:我是该工具的开发人员之一

超过200条代码规则 是默认建议的。借助众所周知的 C# LINQ 语法,自定义现有规则或创建自己的规则非常简单。

可以在 Visual Studio 中实时验证规则,并在构建过程中在 生成的 HTML+javascript 报告

An alternative to FxCop would be to use the tool NDepend that lets write Code Rules over C# LINQ Queries (namely CQLinq). Disclaimer: I am one of the developers of the tool

More than 200 code rules are proposed by default. Customizing existing rules or creating your own rules is straightforward thanks to the well-known C# LINQ syntax.

Rules can be verified live in Visual Studio and at Build Process time, in a generated HTML+javascript report.

暖伴 2024-09-13 02:58:04

另一种选择可能是将 FxCop 可执行文件作为构建任务调用(来自 msbuildtasks),将结果保存为 XML 文件可以在大多数 CI 工具(例如 Hudson 和 CC.NET)中进行解析

Another option might be calling FxCop executable as a build task (from msbuildtasks), saving the result as an XML file that can be parsed within most of the CI tools (like Hudson and CC.NET)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文