20

I have a Build Definition to build a solution on my TFS. This works well, but it always builds the latest version.

  1. How can I force to build a specific changeset from the past?

  2. How can I use/pass this number to the "MSBuild Arguments" to use it there for deployment?

Dylan Smith
  • 22,069
  • 2
  • 47
  • 62
Konrad
  • 4,329
  • 10
  • 54
  • 88

3 Answers3

28

When you queue up the build from Team Explorer, in the Parameters tab one of the Advanced arguments is get version.

Note: I think you need to specify this in the form C123 where 123 is the changeset number.

Dylan Smith
  • 22,069
  • 2
  • 47
  • 62
  • thank you ... that anwsered the first question ... but how can I pass this parameter (C1234) to the MSBuild Arguments to use it for deployment? – Konrad Nov 04 '11 at 08:14
  • 2
    It's in one of the workflow arguments, you can access that when setting the arguments passed to the msbuild (you'd have to customize the build workflow) – Dylan Smith Nov 04 '11 at 14:54
10

The answer to your first question is clearly what @Dylan has stated.

To your second part:
The important argument is GetVersion. Navigate to activity "Run MSBuild for Project" within your Build Process Template, by default this has a value CommandLineArguments equal to

String.Format("/p:SkipInvalidConfigurations=true {0}", MSBuildArguments)

You can change it to something like

String.Format("/p:SkipInvalidConfigurations=true {0} /p:DeployIisAppPath=/changeset/{1}", MSBuildArguments, GetVersion)

and get where you need to go.

pantelif
  • 8,524
  • 2
  • 33
  • 48
  • Creating a new template is the way to go. I only had to change "GetVersion" into "BuildDetail.SourceGetVersion" to get the latest build version :-) – Konrad Nov 08 '11 at 07:03
  • My current *Build process file* is set to *TfvcContinuousDeploymentTemplate.xaml*, however I can't find that file in the *BuildProcessTemplates* folder. – Shimmy Weitzhandler May 01 '15 at 02:34
0

If you use the changeset number, then it will only make sense for CI builds, since they typically build a single changeset.

For any other kind of build, I recommend using the build ID, which is unique, and covers the case of a build that builds multiple changesets.

John Saunders
  • 160,644
  • 26
  • 247
  • 397