Microsoft have just released a new command line tool for computing the same code metrics that Visual Studio provides. These include Maintainability Index, Cyclomatic Complexity, Class Coupling, Depth of Inheritance, and Lines of Code. The tool is named Metrics.exe and can be downloaded here.
The results will be placed in an XML file whose schema matches the provided MetricsReport.xsd. Jakob Ehn has already documented how to integrate this with TFS 2010 Build. All that’s needed is an XSL file to integrate with CruiseControl.NET.
Thanks to Cameron Skinner for the announcement of the tool.
Update (1 Feb 2011): Please note that .NET Framework 4.0 is required for this tool. Also it requires version 10.0.0.0 of Microsoft.VisualStudio.CodeAnalysis.Common so you should have Visual Studio 2010 installed.