title: How would I create a Custom TFS Checkin Policy to check code for coding standards?
body: <p>I am working with a tremendous amount of legacy code written to various code standards over the last 15+ years. Currently, we use TFS for our version control, changing is not an option. Rewriting all the legacy code to current standards at one time is also not an option. The code base, needs to improve in order for us to decouple our various layers and move to a model more like MVC. </p>
  
  <p>What I am looking for is a way to run some form of custom code analysis on just the files being committed at the time. Something along the lines of a regex check for certain strings in files where they shouldn't exist (e.g. ExecuteScalar() in an aspx.vb file) Essentially, I want to know if developers are writting code that doesn't match our standards, or if the files they are committing contain code that doesn't match our standard. The idea being, that we will immediately force developers to write code to standards, and incrementally update the files they are working with to current standards. Over time this should result in a cleaner code base.</p>
  
  <p>I have been working my way through the MSDN Documentation for TFS Checkin policies but I'm not really finding what I'm looking for. Most of the documentation seems to refer to running Code Analysis on the entire project and creating work tickets for cleanup. A possible solution, but less than ideal.</p>
  
  <p>Are there any prewritten custom TFS Checkin Policies that do this? If not, how would one go about writing something like this?</p>