How to: Make Team Build get a previous version

In Team Build 2008 there is a property called GetVersion. Here’s what the description from Aaron Hallberg’s blog says about it:

GetVersion.  Passed to the Version property of the Get task.  Defaults to SourceGetVersion (see below), but can be overridden to retrieve a particular version from source control.






To use this property to build a previous version of the source code you have three options:

Additional MSBuild Parameters dialog

Queue a new build and in the “Additional MSBuild Parameters” box, put:


Where XXXX is the changeset you want to build. See screenshots here.

TFSBuild.rsp – MSBuild Response file

Or, put the same option in the TFSBuild.rsp (response) file. The contents of this file are passed as command line parameters to MSBuild.



Or, Add a property into the TFSBuild.proj Team Build project file.






You don’t have to specify a changeset either. You can specify any valid versionspec. See the versionspec heading under Command-Line Syntax for more options.

With TFS 2005 you would have needed to change the core implementation of Team Build.
See Aaron Hallberg’s “Building a Specific Version with Team Build” blog.



Another thing to keep in mind is – What version of TFSBuild.proj will you be using to build the previous version of the code? What I typically do is store the TFSBuild.proj file alongside the source code in the branch. That way when you branch the code and you need to make build script changes, they are isolated and merged back with the code changes.

Comments (8)

  1. How Do I: Use the Checksum and ExpectedSchema Database Test Conditions Tommy Norman on TFS API: Work…

  2. xwang says:


  3. brotherjay says:

    How about an updated post about this for Team Build 2010?  I can see the GetVersion parameter on the Queue Build parameters tab, but it doesn't seem like it works.  The build still says "triggered by…changeset..xxxx" which is the most recent even when I specify an older changeset.

  4. Ervin says:

    Try creating a shelveset from that changeset and then specifying that shelveset in the build definition or build dialog (as oppossed to 'latest').

  5. Gogs says:

    brotherjay is right. an updated post for Team Build 2010 would be very nice. Does anyone know how that works?

    I also tried this Get Version option in my Build Definition ->Process->3.Advanced->MSBuildArguments:/p:GetVersion=CXXXX, but this didn't work. Same for Queue Build->Tab Parameters->2.Advanced->MSBuildArguments:/p:GetVersion=CXXXX

    Any known solution?

  6. Fatih says:

    Is there any chance to get more than one changeset at a time? i mean getting the changeset numbers: C3122,C3123,C3515.