Paul Hacker's Blog

Musings from a "Hacker"
posts - 21, comments - 65, trackbacks - 22

My Links

News



Archives

Tuesday, May 02, 2006

Add a Custom Check-In policy to Team Foundation Server

I decided that I wanted to implement a custom check-in policy for no other reason that to have the knowledge on how it is accomplished. I ran across a great policy on James Mannings' blog that can be found here http://blogs.msdn.com/jmanning/archive/2006/01/21/515858.aspx. This a a policy that requires the user to enter comments when checking in code.

In order to use the policy you will to complete a few simple steps.

  1. Create a new C# Class library project. Give the project a descriptive name like CustomCommentsPolicy.
  2. Add the following refernces to the project     System.Windows.Forms   and Microsoft.TeamFoundation.VersionControl.Client
  3. Build the project in Release configuration

Now that you have built the project you will need to add a registy entry in the policy section of the registry for TFS. When a user accesses the dialog to set the policies for the project, they are read from the registry. The following steps will help you accomplish the task.

  1. Access the registry and locate the following key HKEY_LOCAL_MACHINE\Software\Microsoft\VisualStudio\8.0\TeamFoundation\SourceControl\Checkin Policies
  2. You should see registered policies in the right hand pane. Right-click and select New > String Value
  3. Set the name to the name of the assembly without the .dll extension. In my case it is CustomCommentsPolicy.
  4. Set the value as the path to the .dll file that was created when you build the project.

Thats it. You now have a policy setup and ready to use.

Fire up VS2005 and access your project in Team Explorer. Navigate to the check-in policy dialog, click Add, and you should see your new policy in the list. Add it to you project, make a change to the source and perform a checkin. If everything worked as expected you will get notified that you new policy was not met. Add some comments and complete the checkin. All should work well this time and you will not get a policy failure notification.

I know there are a few blogs about this out there, but never hurts to walk through it again.

Hope this helps you out.

pjhacker

                

             

 

posted @ Tuesday, May 02, 2006 7:10 PM | Feedback (7) |

Powered by: