Search code examples
msbuildjenkinsstylecop

Making StyleCop & Jenkins do my bidding


We're trying to set up Jenkins with the latest version of StyleCop.

Our existing Jenkins setup invokes StyleCop via StyleCopCmd via nant, but StyleCopCmd seems to be increasingly out-of-date, and unmaintained; and I’d rather cut it out. So best supported solution seems to be to invoke StyleCop from msbuild.

Our solution consists of multiple projects, but the Jenkins Violations plugin expects a single stylecop.violations.xml file, so the widely documented solution of importing StyleCop.targets and invoking it from each 'csproj' file seems like it won’t work (because this would produce multiple violations files, which the Jenkins plugin can't cope with).

SO:

  1. Is there some way of merging multiple StyleCop violations files so that they are treated as one by the Jenkins Violations plugin, OR
  2. Is there some way, in Msbuild, of peeking into multiple '.csproj' files, extracting the '.cs' files and running them all through StyleCop in a one-er. Alternatively:
  3. Given we're using Jenkins and multiple project files, is there another way of reporting violations for all of the projects in the solution?

Any help gratefully received.


Solution

  • See this: http://ferritedog.wordpress.com/2011/05/27/1-hour-guide-to-continuous-integration-setup-jenkins-meets-net/

    Basically, use the XML FileName Pattern **/*/StyleCopViolations.xml.