Technology Toolbox

Your technology Sherpa for the Microsoft platform

Jeremy Jameson - Founder and Principal



Bypassing a Gated Check-in in TFS 2010

This post originally appeared on my MSDN blog:

Since I no longer work for Microsoft, I have copied it here in case that blog ever goes away.

Yesterday someone contacted me about my earlier post on Incrementing the Assembly Version for Each Build in TFS 2010, because after following the steps I provided, he encountered a problem due to the fact that he had previously configured a gated check-in build that included the folder containing the AssemblyVersionInfo files.

The problem is that after you create a gated check-in build definition, the tf.exe checkin command does not actually check-in your changes, but rather shelves your changes until the gated check-in validates the changeset (at which point, the files are checked in on your behalf). In this case, the tf.exe checkin command does not return 0 and the original build (that was attempting to check-in the AssemblyVersionInfo files) consequently fails.

Fortunately, the Visual Studio folks have provided a way to bypass gated check-ins (provided a user has been granted permission to do so). Therefore, to avoid the issue when incrementing the assembly version for each build, you first need to grant the appropriate permission to the serice account used to perform your builds.

To grant permission to bypass a gated check-in:

  1. In the Team Explorer window, expand the appropriate project, right-click Builds, and then click Security...
  2. In the {Project} Security window, in the Add users and groups section, click Windows User or Group, and then click Add...
  3. In the Select Users, Computers, or Groups window, type the name of the service account used for TFS builds (e.g. TECHTOOLBOX\svc-build), and then click OK.
  4. In the {Project} Security window, in the list of permissions, for the Override check-in validation by build permission, click the checkbox in the Allow column, and then click OK.

Then you simply need to modify the IncrementAssemblyVersion.proj file (described in my previous post) to specify the /bypass option with the tf.exe checkin command.

  Command="$(TeamFoundationVersionControlTool) checkin /bypass /override:&quot;Check-in from automated build&quot; /comment:&quot;Increment assembly version ($(IncrementedAssemblyVersion)) $(NoCICheckinComment)&quot; AssemblyVersionInfo.txt AssemblyVersionInfo.cs"/>

Once you have made these changes, the build that increments the assembly version will run without issue.

For more information on gated check-ins, refer to the following:

Define a Gated Check-In Build to Validate Changes

In case you are wondering how I configured the gated check-in build definition, here are the settings I used. If a setting is not listed in the following table, it means the default is used.

Build Definition: "Gated Check-in - Main"
General Build definition name Gated Check-in - Main
Trigger Gated Check-in - accept check-ins only if the submitted changes merge and build successfully (selected)
Workspace Source Control Folder
Build Agent Folder
Build Defaults This build copies output files to a drop folder (not selected)
Process Build process template: DefaultTemplate.xaml
Build process parameters:
Items to Build
  • Solutions/Projects
  • Configurations

  • $/foobar2010/Main/Source/TechnologyToolbox.Foobar.sln
  • Release - Any CPU
Clean Workspace False
Perform Code Analysis Never
Source And Symbol Server Settings
  • Index Sources

Agent Settings
  • Maximum Agent Execution Time

Copy Outputs to Drop Folder False
Create Work Item on Failure False
Label Sources False



No comments posted yet.

Add Comment

Optional, but recommended (especially if you have a Gravatar). Note that your email address will not appear with your comment.
If URL is specified, it will be included as a link with your name.

To prevent spam from being submitted, please select the following fruit: Watermelon

Please add 3 and 8 and type the answer here: