TFS 2010 : How to apply check-in policies to only certain branches or folders

This question keeps coming up frequently, and so I thought to make a succinct post on how to do this.

 

First install the TFS 2010 Power Tools by downloading it to your Client box. You can do a bing search to locate the “TFS 2010 Power Tools download”. This has to be installed on each Client box on which Visual Studio 2010 is installed.

Then go to Source Control as shown below:

image

Once you installed the Power Tools, you should see a new set of Check-in policies in place as shown below.

SNAGHTML830358b

 

Note that it says that “This policy scopes other policies to specific folders or file types, and there you have it. So what it means is essentially you could create some other policy and use that as a child to this policy and then constrain it to be triggered for checking only if the check-in happens to go under the folder or branch that you specify in its scope.

 

clip_image004

 

To further illustrate this:

Below I have created a “Code Analysis” policy, and then used it as a Child policy for the “Custom Path policy” and scoped it to apply to the “DEV” branch. You can just enter a matching string for regexing into the particular branch you want to.

If this is not what you are seeking, then you might also consider writing a custom check in policy. Note that policies are evaluated at the client prior to checkin.

clip_image002

 

That’s all there is to this.