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. Error handling is only rudimentary - plenty of room for improvement.

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.

License

Source for StyleCop Cmd is under the MIT license. You are free to use and adapt the source in your own applications.