views:

120

answers:

1

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?

+1  A: 

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!

Brett Rigby