Wednesday, April 28, 2010

Writing an FxCop Task for MSBuild

I've been working on improving our processes on the ASP.NET MVC team, and one of the things that we wanted to do was have our continuous integration build run FxCop.

Unlike most of the teams inside of the Developer Division, we're actually building ASP.NET MVC on the released versions of Visual Studio. The division has a ton of custom-built tooling, but since we don't live in the same space as they do, we're using the same tools and techniques that you guys use.

When I discovered that FxCop failures don't break the build by default, I went a-Bing'in to find the answer. What I found was several blog posts like this one from Ade Miller that described post-processing the XML file with a custom task to determine if they should fail the build. I think we could do better. I wanted our FxCop failures to feel just like standard build failures, not like afterthoughts with custom reports.

I'm no stranger to writing MSBuild plugins, so I decided it would be worth a few hours to write a task which not only ran FxCop, but parsed the resulting XML and turned it into MSBuild-style warnings and failures as appropriate.

Read more: Brad Wilson

Posted via email from jasper22's posterous