views:

181

answers:

1

I have 3 build scripts that create separate components of a distributed suite of applications. They are stored in a folder structure like the following:

LegacyComponents - VB6 code that is "live" but in the process of being replaced
NewComponents - Rewritten components in C#
Database
TeamBuildTypes
└ LegacyBuild
└ NewBuild
└ DatabaseBuild

In each build folder I have a script named TFSBuild.proj.

Because the builds are separate, they are each given a distinct build number. I need to label each one with a string that ties them all together so that I can "get" a label and have the entire consistent set of code.

I created a file called KitNumber.targets with a KitNumber property and put it in the TeamBuildTypes folder. I then put the following line in each build script:

<Import Project=".\..\KitNumber.targets"/>

I should now be able to change the kit number in one place and have it applied in every build.

This works on my dev box because the source has already been brought down from TFS but fails on the build machine because only the content of the directory containing the build script is brought down.

So where do I store the shared property so that I can use it in each script?

A: 

Using a text file with a single line containing the label that I want to apply:

<Target Name="ApplyKitNumberLabel" Condition="$(KitNumber) != ''">

  <ReadLinesFromFile File="$(WorkspaceRoot)\TeamBuildTypes\KitNumber.txt">
    <Output TaskParameter="Lines"
      PropertyName="KitNumber" />
  </ReadLinesFromFile>

  <Label TeamFoundationServerUrl="$(TeamFoundationServerUrl)"
         Files="$(WorkspaceRoot)\$(BranchName)\LegacyComponents"
         Name="$(KitNumber)"
         Recursive="True" />

</Target>
freshr