StyleCop 与 CI 构建流程集成(Criuse Control、Nant、msbuild 和 StyleCop)
,方式如下:
- 我被要求将 StyleCop 集成到我们的 CI 构建过程中 (大)解决方案不受影响
- 我不必使用任何第三方 第一个要求
(我还没有完全理解这一点)是因为我们不想立即在整个解决方案上运行 StyleCop。 显然,当 StyleCop 从 VS 内运行时,它会忽略指定要忽略的文件的某些属性。 因此,如果我们让它在开发机器上运行,我们将不断受到数千个我们尚未准备好处理的违规行为的影响。 所以底线是我们希望能够仅在构建服务器上运行它。
我们的构建环境目前包括:
Cruise control > 执行 msbuild 的 nant 任务(通过 exec)
nant 任务如下:
<target name="buildSolution">
<echo message="Building solution..." />
<exec program="C:\WINDOWS\Microsoft.NET\Framework\v3.5\msbuild.exe"
commandline="${Project.SolutionFile} /t:Rebuild /p:Configuration=${Project.SolutionBuildConfiguration} /v:q" workingdir="." />
</target>
当我第一次看到这个时,我认为这将是一个以与执行 msbuild 类似的方式执行 StyleCop 的简单情况。
然而,StyleCop 作为一组 dll 出现......
所以这意味着我不能做我想要的......我想......
我今天用 google 搜索的所有文章都说“使用 StyleCopCmd”,我也不能由于第 3 方工具限制而执行此操作。
我查看了该工具,它似乎实现了一个自定义 nant 任务,该任务启动 StyleCopConsole,挂钩几个事件并输出格式良好的报告。 但为了能够证明内部创建任何工具的合理性,我需要能够充分解释为什么我不能在 nant 配置文件中实现我想要的目标。 或者以任何其他不涉及创建或使用工具的方式。 理想情况下,如果我不必编写或使用工具,速度会更快。
所以我的问题是,这可能吗?
I have been asked to integrate StyleCop in our CI build process in such a way that:
- Individual project file in our
(large) solution are not affected - I don't have to use any 3rd party
tool
The first requirement (and I don't fully understand this yet) is due to the fact that we don't want to run StyleCop on our entire solution straight off. Apparently, when StyleCop is run from within VS it ignores certain attributes that specify files to ignore. Because of this, if we have it running on the dev machines we will continously be hit by thousands of violations we are not yet ready to deal with. So the bottom line is we want to be able to run it only on the build server.
Our build environment currently consists of:
Cruise control > nant task that executes msbuild (via exec)
The nant task is below:
<target name="buildSolution">
<echo message="Building solution..." />
<exec program="C:\WINDOWS\Microsoft.NET\Framework\v3.5\msbuild.exe"
commandline="${Project.SolutionFile} /t:Rebuild /p:Configuration=${Project.SolutionBuildConfiguration} /v:q" workingdir="." />
</target>
When I first looked at this I thought it would be a simple case of executing StyleCop in a similar manner to the way msbuild is being executed.
However, StyleCop comes as a set of dlls...
So this means I cannot do what I intended......I think....
All the articles I have googled today have said "use StyleCopCmd" which I also cannot do because of the 3rd party tool restriction.
I've looked at the tool and it appears to implement a custom nant task that kicks off the StyleCopConsole, hooks into a couple of events and outputs a nicely formatted report. But in order to be able to justify the creation of any tool in-house I need to be able to fully explain why I cannot just achieve what I want in the nant config file. Or in any other way that does not involve creating or using a tool. And ideally, it would be faster if I didn't have to write or use a tool anyway.
So my question is, is that possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们已经成功做到了这一点。 只需按照以下步骤操作:
在项目中创建一个目录,并将所有 StyleCop 文件复制到其中(Microsoft.StyleCop.CSharp.dll、Microsoft.StyleCop.Targets 等)
编辑 Microsoft.StyleCop.Targets 如下所示:
--
将以下任务添加到要运行 StyleCop 的 NAnt 脚本中。 只需将 NAnt 属性替换为对您的构建脚本有意义的属性或值即可。
We've managed to do this. Just follow these steps:
Create a directory in your project and copy all the StyleCop files there (Microsoft.StyleCop.CSharp.dll, Microsoft.StyleCop.Targets, etc.)
Edit Microsoft.StyleCop.Targets to look like this:
--
Add the following tasks to your NAnt script where you want to run StyleCop. Just replace the NAnt properties with the properties or values that make sense for your build script.