Last week, I made a sample policy for an internal team and got an email today with (basically) “Great! Now how to we add it?”. While the official page on customizing checkin policies details most of the steps, it leaves out one step that for V1 we’re considering to be an issue out-of-band to Team Foundation – getting the policies 1) “installed”, typically copied somewhere on the filesystem of the client machine(s) and 2) a registry key on each client machine pointing at the installed location.
C:\>reg query “HKLM\Software\Microsoft\VisualStudio\8.0\TeamFoundation\SourceControl\Checkin Policies” /v ForbiddenPatternsPolicy
! REG.EXE VERSION 3.0
ForbiddenPatternsPolicy REG_SZ C:\Documents and Settings\jmanning\My Documents\Visual Studio 2005\Projects\ForbiddenPatternsPolicy\ForbiddenPatternsPolicy\bin\Debug\ForbiddenPatternsPolicy.dll
Once that registry key is in place (either HKLM or HKCU), then the rest of the steps on the page should work fine. If you’re not seeing your policy in the list then 1) check to make sure the path in the registry is correct 2) make sure your policy class is *really* public (if it doesn’t have the public keyword in front of the class, it isn’t), marked with the Serializable attribute, and has a no-args constructor 3) try loading the assembly to see if there’s any problems getting it loaded.