Run SPDisposeCheck as part of your build process

As mentioned before, I’ve been automating the building and analysis of our SharePoint code, and this led me to ask, can you run SPDisposeCheck as part of a TFS build process?

Yes we can. Richard Fennell has a concise and simple description of how to do it. It’s best to read that, but in case that site goes down, the short of it is – use InvokeProcess to run SPDisposeCheck, and it’ll return a value that is the number of errors/warnings it finds. I find that that’s enough to choose whether to write a warning to the output of the build, and I don’t then parse and write the individual warnings into the build. These should be captured by the build log, and they’re pretty obvious, so it doesn’t seem worth the hassle. You could do it if you really wanted to.

Don’t forget you can use attributes to prevent false positives – though I still have issues with anonymous delegates that are false positives (how do you add the attributes?), and that’s what’s causing the two warnings above.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>