There is a noticeable omission form the tooling for StyleCop that you cannot integrate it into a TFS 2010 Build directly. There is a custom task to do it as part of MSBuild Extension pack, but this is designed for TFS 2008.

So when I had to wire in StyleCop to our 2010 build process I hit a problem, I could

  1. Edit the .csproj files for each project to wire in StyleCop
  2. Use an MSBuild activity in my 2010 build
  3. Write my own custom activity.

I decided to follow the final option, it did not look too bad as the source needed is provided in the StyleCop SDK. Well after a good deal of fiddling I have it basically working. Again I found the process of developing a custom activity a little irritating.

I cannot state enough times the way to do this type of development is

  1. Create the activity, unit testing if possible
  2. Create a WF console application to host it
  3. For each activity property wire it to an argument on the workflow WF console application
  4. Create a test project to run unit tests against this workflow
  5. Only when this all works go down the painful route of getting it linked into a real build

The main problem I had was that StyleCop was running fine, but finding no violation when I knew some were in my test data. This all turned out to be down to where the Microsoft.StyleCop.dll assembly was being loaded from, and whether there were any rules assemblies in the same directory. I have to admit I only got to the bottom of this after getting all the source for StyleCop so I could debug into it!

So I now have the first pass at StyleCop custom activity for TFS 2010, needs some more testing, but I think I am just about there. I intend to get it up on http://tfsbuildextensions.codeplex.com/, just need to make sure it meets all the guidelines.

So is there any interest in this activity?