Team Foundation Server’s build system serves as the “heartbeat” for your development lifecycle. It automatically creates relationships between code changes, work items, reports, and test plans.
But once in a while I’m asked, “What if we don’t use TFS Build for building our application, but we still want to have builds in TFS so we can track and associate work?” Besides the biased question of “Why NOT use TFS Build, then?!”, there is sometimes the need to leverage the benefit of having empty/fake builds in TFS that don’t do anything more than create a build number/entry in TFS.
There are a couple scenarios where this makes some sense, but the most common one I hear is this:
Without builds in TFS, it’s near impossible (or at least very inconvenient) to tie test plans (accurately) to the rest of the lifecycle.
Luckily, TFS 2010’s build system is incredibly flexible: flexible enough to allow us to “fake” builds without actually performing build actions (get source, compile, label, etc.). It’s surprisingly simple, actually; and it doesn’t require writing any code.
In my example (which I’ll detail below), I define a build which doesn’t do much more than craft a build number and spit out some basic information to the build log.
First, create a new build process template, based on the default process template, using the steps described in this MSDN article.
Once you have the process template created and registered in TFS, open the new template (.xaml file) in Visual Studio. It will look (collapsed) something like this:
Here’s where it gets fun. Inside the outermost sequence, delete every sequence or activity except for “Get the Build”.
Drag an UpdateBuildNumber activity from the toolbox into the sequence, after “Get the Build”.
(optional) Rename “Get the build” to “Get Build Details” so there’s no implication that an actual build will take place".
Now expand the Arguments section (at the bottom of the XAML Designer window). Delete all arguments except for BuildNumberFormat, Metadata, and SupportedReasons.
At the bottom of the now-shorter list, use “Create Argument” and create the following arguments:
“MajorBuildName” and “MinorBuildName” will be used to help manually name each build. “Comment” will be used to capture any notes or comments the builder wants to include for a given build. “IncludeBuildDetails” will be used to determine if additional summary information about the build will be written to the build log.
To provide users with means to set values to these arguments, create parameters in Metadata. Click the ellipsis (…) in the Default value column for Metadata. This will bring up the Process Parameters Metadata editor dialog. Add each of the following parameters:
A couple notes about setting the above parameters:
Your dialog should now look something like the one at right.
Next, open the expression editor for the Value property of the BuildNumberFormat argument and edit the value to read: “$(BuildDefinitionName)_$(Date:yyyyMMdd)_$BuildID)”. Including the BuildID will help ensure that there is always a unique build number.
Now, Click “Variables” (next to Arguments) and create a new variable named ManualBuildName of type String, scoped to the Sequence, and enter the following as the Default:
If(String.IsNullorEmpty(MinorBuildName), MajorBuildName, MajorBuidName & “.” & MinorBuildName)
This variable will be used to provide a manual build name using the supplied MajorBuildName and MinorBuildName arguments.
Now we have all the variables, arguments, and parameters all ready to go. Let’s put them into action in the workflow!
Drag a WriteBuildMessage activity into the main sequence, before Get Build Details, with these settings:
Next, add an “If” activity below “Get Build Details” to evaluate when to include additional details in the build log, with the following properties:
In the “Then” side of the “If” activity, add a WriteBuildMessage activity for each piece of information you may want to include in the build log. In my example, I included 3 activities:
Your “If” activity will look like this:
The last thing to do is to add an UpdateBuildNumber activity as the last element in the main sequence, with the following properties:
This last activity will actually create the build number which will be stored back into TFS. Your completed workflow should look like this:
Now go back to Source Control Explorer and check this template back into TFS.
Go create a new build definition, opting to use your new template on the process tab. You’ll notice that your options are dramatically simplified:
Specify a value for Major Build Name and save your new definition.
Queue the build and you’ll see the following on the Parameters tab:
Enter some basic information and click “Queue” to run the (fake) build.
What you end up with is a build that completes in just a couple seconds, does pretty much nothing, but includes your specified information in the build log:
And just to be clear, my example adds more “noise” into the build than you may find necessary, with additional build information, comments, etc. You could streamline the build even more by removing the “Include Build Details If Chose” activity (and all its sub-activities).
Given the overall flexibility TFS 2010 has with incorporating Windows Workflow into the build system, there are undoubtedly other ways to accomplish variations of this type of build template. But I had fun with this one and thought I should share. I’ve posted my sample template’s xaml file on SkyDrive here:
I’m all ears for feedback!
TFS Preview is just that – a preview. So things may not be where you’d think they are, especially if you’re used to the current version of Team Foundation Server.
I was recently asked (twice), “Okay, so I’ve got my account and project collection established, how do I get more people added to the environment so we can do some team development?”
Here’s the quick way:
For a broader overview of setting up groups, users, and security, I recommend taking a look at this video tutorial. There are several other video tutorials that you can watch, all from the Administration page on your TFS Preview site.
If you’re in SoCal somewhere, you may want to take advantage of this FREE “quick start” event, offered by HarborObjects.
For registration and additional details, visit their events page, but below is a teaser of what you’ll learn during this event:
The goal of this training is to quickly bring you up to speed with the essentials features of Team Foundation Server 2010 so that you can quickly setup and be productive in your own TFS environment. We start out by outlining a generic development process which embodies basic activities that are encountered in any software development process. We'll use those activities as the context in which you'll learn to use TFS and you'll be able to easily map those activities into the process that you use in your own development work.
The goal of this training is to quickly bring you up to speed with the essentials features of Team Foundation Server 2010 so that you can quickly setup and be productive in your own TFS environment.
We start out by outlining a generic development process which embodies basic activities that are encountered in any software development process. We'll use those activities as the context in which you'll learn to use TFS and you'll be able to easily map those activities into the process that you use in your own development work.
2012 Event Dates:
Again, visit the events page to register, and we hope to see you there!
I receive a lot of email each week from you asking very specific, and valuable questions. It’s my hope that a newsletter like this will help me communicate important announcements, tips/tricks, and other items to help you and your team ultimately be more successful!
Yep, I’ve added virtual office hours to my plate in an effort to get your questions answered! I’m holding them for an hour every 2-3 weeks – I hope you stop by sometime! My next office hours are next Friday, 11/18 at 9:30am Pacific.
If you’re using using Visual Studio 2010 and TFS 2010 (and possibly Test Professional 2010), you may want to download and take advantage of the “Visual Studio 2010 SP1 TFS Compatibility GDR” update, now available. It contains several fixes, and even the addition of a highly-requested feature in MTM (multi-line test steps)!
The OData Service for Team Foundation Server 2010 is not officially released! Brian Keller has more here.
If you’ve been playing with the VS 2010 virtual machine with labs and sample data, it’s been refreshed with a new expiration date. Again, see BrianKel’s blog for details.
Did you know you can “fake” a TFS build? This is useful if you don’t actually use TFS as a build system, but still need build numbers to load into TFS to help associate items together (i.e. changes between “builds” for testing purposes).
Want to get access to TFS Preview but don’t have an invite code? Ping me, let’s talk.
Are you going to the ALM Summit next week in Redmond? I am, and I hope to see you there!
November 17, 2011 Coffee Talk: Scrum-damentals (free webcast)
November 28, 2011 LIVE event in Edina, MN: Double Feature: Testing & ALM for Agile Development For Details or to Register, Click Here
November 29, 2011 LIVE event in San Diego, CA: Double Feature: Testing & ALM for Agile Development For Details or to Register, Click Here!
November 30, 2011 Visual Studio 2010 ALM Tools Live Roadshow Denver, CO
My team has access to programs (and funds to help pay for them) to help you and your organization get ramped up on all sorts of topics and technologies:
Send me a note and let’s see where I can help!
Why is 'abbreviated' such a long word?