0

I want to be able to run a StyleCop analysis as a build step on our build definition, but am coming across some issues. I can't use this because our TFS policies forbid external build steps. I would prefer to not use this method either as it appears that it runs an analysis every time it builds (and we don't want this to happen on development machines).

Ideally I'd like to be able to run the analysis from batch or PowerShell as a build step, but that doesn't appear to be an option.

What methods are available that allow me to run a StyleCop analysis on an existing project (which already has StyleCop installed) as a build step in TFS Build, without it running each time the software is compiled on a development machine, and without adding too much bloat to the software?

AidanH
  • 502
  • 5
  • 24

1 Answers1

1

You could check StyleCopCmdLine. StyleCopCmdLine is wrapper project to make it possible to easily call StyleCop from a command prompt or a PowerShell script.

For a discussion of its usage within a TFS 2015 vNext build see this blog post.

Cece Dong - MSFT
  • 29,631
  • 1
  • 24
  • 39
  • Hi thanks for the recommendation. I downloaded the repo and it builds just find. I tried to run the 'sample.bat' script which is meant to return that the file has 7 errors, but I don't get any violations. I've also tried running this on a project I have which definitely has errors, and it doesn't detect those either. Here's the log: https://pastebin.com/vfbw0Qhx – AidanH Jul 25 '18 at 08:59
  • I've created a new question for the issue I posted above: https://stackoverflow.com/questions/51516214/stylecopcmdline-not-detecting-violations – AidanH Jul 25 '18 at 10:07
  • Which version of StyleCop do you use? You may try to open your issue here: https://github.com/rfennell/StyleCopCmdLine/issues. – Cece Dong - MSFT Jul 26 '18 at 09:52
  • When I do the analysis on the source files in our project, it does it using StyleCop 5.0 - but in the pastebin, it mentions the addin-paths go to StyleCop 4.7 when using StyleCopCmdLine, ill see if I can open an issue – AidanH Jul 26 '18 at 10:11
  • Just solved it. See https://stackoverflow.com/questions/51516214/stylecop-from-c-sharp-wrapper-not-detecting-violations/51536677#51536677 for the answer - therefore your answer is correct – AidanH Jul 26 '18 at 10:30