Showing posts with label fxCop. Show all posts
Showing posts with label fxCop. Show all posts

Monday, April 2, 2012

Jenkins Violations plugin quirk

Now that I got OpenCover working with Jenkins, I decided to go after fxCop. Here's the command-line I settled on:

"C:\Program Files (x86)\Microsoft Fxcop 10.0\fxcopcmd.exe" /oxsl:none /igc /f:OurApp.AssemblyToCover1.dll  /f:OurApp.AssemblyToCover2.dll /out:fxcop_results.xml /d:"c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies"

The /oxsl: argument specifies no xsl transformation on the output (I'm using the Violations plugin which reads the native xml).

The /d: argument points to where System.Web.Mvc.dll lives, which one of our assemblies depends on.

As I mentioned before, I want to exclude several assemblies from analysis, so I specified the ones I want included by using /f: arguments (one per assembly).

NOTE: Getting the Violations plugin to work was easy once I realized one thing: the "XML filename pattern" must either be a filename pattern only (in which case the file will be in the Jenkins build project's workspace directory) or it must be in a directory below the Jenkins build project's workspace directory (for example results\fxCop*.xml) Absolute paths and relative paths starting with "..\" do not work.

Thursday, February 2, 2012

Trying to get .Net Metrics Computed and Displayed with Jenkins

I'm helping a .Net team stand up Jenkins as their CI server. The build steps we have so far are building a solution and running fxCop against the debug build. Using the Jenkins Violations Plugin, which supports fxCop, we can display a nice trend chart and have hot links to drill down and see the violations in context.

My next goal was to run metrics that my team agreed on, specifically Cyclomatic Complexity and Coupling. I was hopeful because Visual Studio 2010 can already compute them. But I found out that Visual Studio's code metrics can't be called on the command line. 

Fortunately, I found Visual Studio Code Metrics PowerTool 10.0 for that purpose. There's lots of information already out about using it: Jeff Bramwell has a blog post about the PowerTool and Cameron Skinner wrote one about it.

Unfortunately, the Violations Plugin doesn't support the xml output, and the PowerTool doesn't have an option to output to HTML. Fortunately, though, Skinner also wrote a post that provides an xslt and a .css file that will turn the results into HTML.

So my next step was to make a build step that runs a command-line tool to apply the transform. I couldn’t figure out or find enough documentation on msxsl.exe, but I found this CodeProject project and it works. (Anyhow, it would only take a few lines to write your own in C# because you can use calls from MSXML.)

Now I need to figure out how to use the HTML report in Jenkins. I'll investigate the Jenkins HTML Publisher Plugin.