StyleCop Cmd
StyleCop is a C# source code convention checker - a tool you can (and should) use to ensure that all the C# source code being written by your team is structured in a consistent and readable stye.
StyleCop Cmd is a simple commandline version, allowing you to integrate StyleCop with other build tools like Nant and with continuous integration suites like CruiseControl.Net and TeamCity.
Released in May 2008 by Microsoft, it appears that StyleCop has been in internal use for some years. The Visual Studio integration is superb, as is the integration into MSBuild.
StyleCop.cmd is a simple command line driver that invokes the StyleCop SourceAnalysis engine to analyse C# source code.
The download is source code only - you'll have to compile it yourself with Visual Studio 2008. Error handling is only rudimentary - plenty of room for improvement.
If there is interest in doing so (email me!), I'll move it to CodePlex for community development, probably as a contribution to a StyleCop.Contrib project or similar.
Not quite what you're looking for? Check out StyleCopCmd, an independent project with the same name (and similar intent) as this tool.
System Requirements
- .NET 3.5 SDK or Runtime
- StyleCop - download from Microsoft
- Visual Studio 2008 - to compile the source.
Operation
Use the -settings flag to identify a Settings.SourceAnalysis file to control the analysis. If you omit this setting, the analysis engine will crash.
After -settings, pass the names of any files you want to analyse. If you list a .csproj file, all of the .cs files compiled by the project will be included for analysis.
Normal logging is to the console, but can be redirected to an xml file by the -xml option.
Version History
v1.1 - Update (27 July 2008)
- Now includes guidance on command parameters
- Minor changes to the output schema used by the XML
- Introduces support for XSLT stylesheet (-xsl) to generate output.
v1.0 - Initial release (1 July 2008)
- Initial release.
- Logs to console or xml.
| Attachment | Size |
|---|---|
| StyleCopCmd-1.1.27.5997.zip | 14.13 KB |
Comments
TeamCity Integration
This is a great tool, thanks for taking the time to make it.
How would one go about getting this to work with TeamCity?
Great Tool!!!
I truly appreciate the hard word that went into creating it!
Using NAnt
Hi,
This looks great. I've not tried it yet (on my Linux laptop at the mo sat at the folks), was just wondering a few things.
Does it return error codes, ie an array of codes, or just 1 = fail?
I'm always playing around with our build at www.huddle.net, and like using NAnt. It would be handy to be able to fail the build if someone has committed bad code.
No error code - yet
As currently written, it doesn't return any error code, as in my situation I didn't want to fail the build on the strength of a style issue.
However, you should find it pretty easy to add - just modify StyleCopDriver.Execute() to return a the count of violations in mViolations.
I may make this change myself, if I get the time - but would equally be happy to roll in a patch if you make the change yourself.
Keep Smiling,
Bevan.
Trouble to build stylecop project
Hello,
I´m trying to build stylecop project but it is required Microsoft.SourceAnalysis?
Where can I find this libs?
--
Thank you in advance
Fernando Guedes Camargo
Special Projects, Inovation and Research
Cinq Technologies
www.cinq.com.br
+55 41 3091-2900
+55 41 9123-6091
You'll need StyleCop as well as StyleCopCmd
Hi Fernando.
The StyleCopCmd project you see here is just a front end to Microsoft's own StyleCop product, intended to make it easier to use StyleCop within a Continuous Integration environment.
To compile my StyleCopCmd you need to download StyleCop from Microsoft as well.
Before you start using StyleCopCmd, I recommend you fully evaluate StyleCop to see if it meets your needs.
The original StyleCop is a free download from Microsoft here:
http://code.msdn.microsoft.com/sourceanalysis
Hope this helps,
Bevan.
Help in setting up StyleCopCmd with VS 2008
hi,
Can anyone help me with setting up the StyleCopCmd with VS 2008?
I have already installed the following :
NET 3.5 SDK or Runtime
StyleCop - 4.3.3.0
Visual Studio 2008
how can I start the StyleCopCmd?
I have download the Zip file and build the code but I still dont get any output
in the cmd what is the exact command that needs to be run?
what I gave was :
Thanks
pubu
Some pointers
Compiling
StyleCop Cmdwill give you the tool - look for StyleCopCmd.exe in the build output directory.Copy the tool + supporting files into a folder, then you'll be able to run the tool over your own project.
Run
StyleCopCmd.exeby itself (with no command-line flags) to see a summary of syntax.IIRC, you'll want to do something like this:
Hope this is helpful,
Bevan.
The download link is broke
Hi,
I'd love to try your cmd line plugin for StyleCop, but it appears the download link is broken.
Download link Fixed
Found the problem and fixed things up. Sorry for the inconvenience.
Bevan.