将 StyleCop 集成到 NAnt 构建脚本中
有没有办法将 StyleCop 集成到 NAnt 脚本中,这样如果样式违规太多,构建就会失败?
StyleCop 似乎没有 NAnt 任务,但我们找到了 StyleCopCmd。然而,这似乎只生成一个 XML 文件作为我们必须解析的输出。有更简单的解决方案吗?
Is there a way to integrate StyleCop in a NAnt script such that the build fails if there are too many style violations?
There doesn't seem to be a NAnt task for StyleCop, but we've found StyleCopCmd. However this only seems to generate an XML file as output that we'd have to parse. Is there some easier solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的 - 我上周就在工作中设置了 StyleCop! (我没有使用 StyleCop 以外的任何东西...)
基本上,我需要做的就是让 StyleCop 在 Visual Studio 2008 中工作,确保我的代码库通过了所有警告,然后更改了.csproj 文件使其结果显示错误,而不是警告。
然后,当我运行相同的 NAnt 脚本时,构建应该像以前一样通过。
但诀窍是返回到您的代码,违反其中一条规则,但退出 VS2008,然后运行您的构建脚本。该代码应该不符合 StyleCop 规则并导致您的构建失败。
希望这有帮助!
Yes - I set StyleCop up at work just last week! (I didn't use anything other than StyleCop...)
Basically, all I needed to do, was to get StyleCop working in Visual Studio 2008, making sure that my codebase passed all of it's warnings, and then changed the setting in the .csproj file to make it's findings Errors, instead of Warnings.
Then, when I ran the same NAnt script, the build should pass as before.
But the trick is to go back into your code, violate one of the rules but quit out of VS2008 and then run your build script. The code should fail the StyleCop rule and fail your build.
Hope this helps!
您根本不需要对 NAnt 做任何事情。
您只需执行两件事:
您可以在此处找到该过程的更详细描述:
http://blogs.msdn .com/b/sourceanalysis/archive/2008/05/24/source-analysis-msbuild-integration.aspx
之后,StyleCop 将在每个构建上运行,无论在什么机器上(并且无需在每台机器上安装它)机),无论构建是如何启动的(从 Visual Studio、从 MSBuild...)。
因此,只要 NAnt 调用 MSBuild 来实际构建解决方案,StyleCop 也会运行。
You don't need to do anything with NAnt at all.
You just have to two things once:
You can find a more detailed description of the process here:
http://blogs.msdn.com/b/sourceanalysis/archive/2008/05/24/source-analysis-msbuild-integration.aspx
After that, StyleCop will run on EVERY build, no matter on what machine (and without installing it on each machine) and no matter how the build was started (from Visual Studio, from MSBuild...).
So, as long as NAnt calls MSBuild to actually build the solution, StyleCop will run as well.
如果您不想通过 MSBuild 执行此操作,可以使用 StyleCopCLI http://stylecopcli.sourceforge.net /
In case you don't want to do it thru MSBuild, you can do it using StyleCopCLI http://stylecopcli.sourceforge.net/