在 Jenkins for .NET 项目中集成 Stylecop

Integrating Stylecop in Jenkins for .NET project

我已经在 windows 机器上安装了 Jenkins,它正在正确构建 .NET 代码。我已经在 J​​enkins 中安装了 Violations 插件来验证 Style cop warnings 。在构建解决方案时,StyleCop 验证显示在 Jenkins 控制台输出页面中,如下所示

  C:\Users\\Properties\AssemblyInfo.cs(32,1): warning : SP2000 : StyleCopPlus.StyleCopPlus :  Invalid spacing at the end of the line. [C:\Users\\\Midhun.csproj]

    1660 Warning(s)
    0 Error(s)

Time Elapsed 00:00:04.35 Finished: SUCCESS

但它在违规页面中没有显示任何内容。

我在 .csproj 中添加以下内容

 <StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>

在那之后,jenkins 构建失败了。但是违规页面仍然空着。

看了那么多文章,还是没能看清楚需要做什么。我找不到任何关于此的分步教程。如果有人可以 post 一步一步的教程或 link 那将是很大的帮助。

我解决了这个问题。以下是解决此问题的详细步骤。

  1. 在 Jenkins 中添加 Violations 插件

  2. 在 post 构建步骤中添加 Report Violations。指定生成 stylecopviolations.xml 文件的位置。

This is file will be created jenkins workspace folder -> Application Folder -> Obj - > Debug - > Stylecopviolations.xml . So in the below section we need to specify as * / */ */ SyleCopViolations.xml .

  1. 现在您将能够在违规页面中看到 stylecop 违规行为

希望对您有所帮助:**/*/StyleCopViolations.xml