Passing custom properties to individual solutions in Team Build

Gautam Goenka posted an article on this topic way back on April 20, 2006.  It included a targets file which overrode the standard Team Build CoreCompile target and allowed user-specified properties to be passed into the MSBuild tast that Team Build uses to build the solution in the SolutionToBuild item group.  This approach is fine if you want to pass the same custom property values into each solution in the SolutionToBuild item group, but what if you want to pass different property values into each solution?

Manish Agarwal posted an article that could help get you started here.  His goal was to enable redirecting assemblies to solution-specific subdirectories, but it was easily extendable to passing other user-specified properties on a solution-specific basis.  Unfortunately, it also some problems, including breaking the calculation of errors/warnings during the compilation phase of the build.

Before pressing on, I should say that we do not recommend overriding the Core* targets in a Team Build build.  The primary reason here is that you will almost certainly be broken after you upgrade to Orcas if you override these targets, since most of them will be changing radically in that new version.  See this post by Buck Hodges for more details here.  The good news here is that the issues that caused people to override the Core* targets in Team Build v1 have been addressed in Orcas, so you should no longer find it necessary to do this sort of thing.

Having said all that, attached you will find a new CoreCompile override that will allow you pass custom property values into each solution via solution-specific metadata.  For example, if you wanted each solution to be signed with a different key file you could do something like:

     <SolutionToBuild Include="$(SolutionRoot)\foo.sln">
      <Properties>SignAssembly=true;AssemblyOriginatorKeyFile=C:\foo.snk</Properties>
    </SolutionToBuild>
    <SolutionToBuild Include="$(SolutionRoot)\bar.sln">
      <Properties>SignAssembly=true;AssemblyOriginatorKeyFile=C:\bar.snk</Properties>
    </SolutionToBuild>

NOTE:  My original example here, which purported to put individual binaries into individual subdirectories, was broken!  Thanks to Esteban Garcia for pointing this out, and sorry for any trouble I might have caused anybody...  If you want to put your binaries into individual subdirectories, try out the new attachment and do something like:

     <SolutionToBuild Include="$(SolutionRoot)\foo.sln">
      <Subdirectory>foo</Subdirectory>
    </SolutionToBuild>
    <SolutionToBuild Include="$(SolutionRoot)\bar.sln">
      <Subdirectory>bar</Subdirectory>
    </SolutionToBuild>

To use this modified CoreCompile target, just:

  1. Download the attached CoreCompileOverride.targets file and check it in alongside TfsBuild.proj.  (Alternatively, you can install this file somewhere on your build machine(s) and modify the import directory in step 2)

  2. Add an <import> statement to your TfsBuild.proj file - something like: 

     <Import Project="$(MSBuildProjectDirectory)\CoreCompileOverride.targets" />
    

  3. Add your custom properties to each item in the SolutionToBuild item group.

Hopefully you'll find this useful!  Let me know via comments if you run into any issues with the attached file, etc.

CoreCompileOverride.targets