One of the properties you specify when creating a new build definition is the build’s drop location. However, this isn’t a statically defined drop location (because if it was each build would overwrite the previous build).
Team Build 2008’s drop location algorithm took the drop location you specified and appended the build number. This generally worked fine except if you had two build definitions dropping to a single folder and you customized the build number generation algorithm to not include the build definition name in the build number.
To work around this Team Build 2010’s drop location algorithm appends both the build definition name and the build number to the drop location. This guarantees uniqueness in the path and will prevent builds overwriting each other and gives you an out-of-the-box solution that just works even if you customize the build number generation algorithm (which is easier in Team Build 2010 than it as in Team Build 2008).
The downside to this new algorithm is if you want to have complete control over the drop location’s structure. For example, lets say you have two build definitions MyApp_Main and MyApp_v1 configured to drop to \\builds\apps\MyApp, the default drop location algorithm will produce this structure:
If I want this (less redundant) structure instead that I’ll have to customize the build process template:
So let’s do that:
- Branch a copy of BuildProcessTemplates\DefaultProcessTemplate.xaml.
- Never edit the DefaultProcessTemplate.xaml directly. You’ll want to keep the original template to refer to, diff against, and to assist when applying service packs with updated build process templates.
- Checkout and open the branched copy of DefaultProcessTemplate.xaml.
- Right-click the Set Drop Location activity (Process\Sequence\Update Drop Location\If Drop Build And Reason is Triggered\Sequence\Set Drop Location) and click Properties.
- Change the DropLocation property from BuildDetail.DropLocationRoot + “\” + BuildDetail.BuildDefinition.Name + “\” + “BuildDetail.BuildNumber to BuildDetail.DropLocationRoot + “\” + If(BuildDetail.BuildNumber.StartsWith(BuildDetail.BuildDefinition.Name + “_”), BuildDetail.BuildNumber.Remove(0, BuildDetail.BuildDefinition.Name.Length + 1), BuildDetail.BuildNumber).
- Configure your build definition to use the branched copy of DefaultProcessTemplate.xaml.
Basically all we’re doing in step #4 is removing the BuildDetail.BuildDefinition.Name directory from the drop location structure and trimming the build definition name (and trailing underscore) off the beginning of the final directory in the drop location structure. If you’ve customized your build number format you’ll need to modify this trimming algorithm to suit.