Paul Hacker's Blog

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

My Links

News



Archives

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

                

             

 

Print | posted on Tuesday, May 02, 2006 7:10 PM |

Feedback

Gravatar

# re: Add a Custom Check-In policy to Team Foundation Server

Ofcourse; all that you have explained here is true.
This is the case when a user copies the file to the client system and changes the registry at the client machine.
What if the policy is installed and registered at the server only. Is there any way to notify the clients about the availablity of the new policy and give them a link to get it and steps to install at their individual systems.
8/11/2006 5:59 AM | NIHAL CHAND
Gravatar

# re: Add a Custom Check-In policy to Team Foundation Server

The policy is installed on "A" client. It is registered with the server and activated. When a user tries to checkin, the policy will be fail and the server can return a message (based on the code in the policy) telling the user how to install it. E.g., from an MSI on the Project Portal.
8/11/2006 6:16 AM | Paul Hacker
Gravatar

# re: Add a Custom Check-In policy to Team Foundation Server

Can any body hav source code for buliding zero build error check in policy?
4/16/2007 3:41 AM | raman
Gravatar

# re: Add a Custom Check-In policy to Team Foundation Server

allegra singulair vestibulitis

best price for the drug singulair

cheapest price on singulair
11/4/2008 2:04 PM | order singulair
Gravatar

# re: Add a Custom Check-In policy to Team Foundation Server

Thanks for the info!
11/22/2008 3:42 PM | levitra for sale
Gravatar

# re: Add a Custom Check-In policy to Team Foundation Server

Excellent article, added to bookmarks.
1/15/2009 3:24 PM | buy propecia
Gravatar

# re: Add a Custom Check-In policy to Team Foundation Server

Very good job. Add your blog to bookmarks.
2/12/2009 1:55 PM | Buy cheapest viagra
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 

Powered by: