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?