Jaa


Bypassing a Gated Check-in in TFS 2010

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.

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

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

https://msdn.microsoft.com/en-us/library/dd787631.aspx

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"
Section Property Value
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 FolderBuild Agent Folder $/foobar2010/Main$(SourceDir)
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
False
  Agent Settings
  • Maximum Agent Execution Time
00:15:00
  Copy Outputs to Drop Folder False
  Create Work Item on Failure False
  Label Sources False