TFS 2010– How to Set Check In Policy


This article demonstrates how to enable Source Code Check-in Policy inside TFS 2010.

image1.gif

Following are the default policies available with TFS.

Policy

Description

Builds

This policy requires that the last build was successful for each affected continuous integration build definition.

Code Analysis

This policy requires that Code Analysis is run before check-in.

Testing Policy

Ensures that tests from specific test lists are successfully run before checking in.

Work Items

This policy requires that one or more work items be associated with every check-in.

image2.gif

Step 1: Install New Policy

We can try adding a new policy that ensures Comments are associated with public methods/properties.
This is a third party plugin and you can download it from CodePlex using the following link: http://tfsccpolicy.codeplex.com/ Use the Download link to download and install the policy executable. You need to restart Visual Studio after the installation.

image3.gif

Step 2: Open Team Explorer inside Visual Studio

image4.gif

Step 3: Open Source Control Dialog

image5.gif

Step 4: Click add button from the Check-in Policy tab

image6.gif

Step 5: Select Check for Comments item

image7.gif

Click Ok button

image8.gif

Please note that the above dialog says we have selected only Public Methods for comment requirement.

Step 6: Test the Check-in

Now we can try creating a file with comment missing for a public method.

image9.gif

Try checking in the file:

image10.gif

On checking in the above file we will get the following error dialog.

image11.gif

Summary

In this article we have explore the source code policy feature of Team Foundation Server and installing a custom Check-in policy.