Calling Custom Targets Within Team Build

In Team Build v1 (VSTF 2005), the CoreCompile target always invoked the Build target of the solutions specified in the SolutionToBuild item group within your TfsBuild.proj file.  To support ClickOnce deployment, an additional item group called SolutionToPublish was supported - all solutions specified in this item group had their Publish targets invoked instead of their Build targets.  Team Build Orcas (VSTF 2008) generalizes this and allows custom targets to be specified for each solution in the SolutionToBuild item group (along with custom properties). 

      <SolutionToBuild Include="$(BuildProjectFolderPath)/path/MyClickOnceSolution.sln">
      <SolutionToBuild Include="$(BuildProjectFolderPath)/path/MyStandardSolution.sln">
        <!-- <Targets>Build</Targets> -->
      <SolutionToBuild Include="$(BuildProjectFolderPath)/path/MyCustomProject.proj">

In this example, MyClickOnceSolution has its Publish target invoked - this will result in the same behavior as if the solution was in the SolutionToPublish item group.  MyStandardSolution does not have a specified target, meaning its default target (Build) will be invoked.  Finally, MyCustomProject; which is not a solution at all, but rather a custom MSBuild project; has its SomeTarget and SomeOtherTarget targets invoked.

This functionality will mostly be useful to those sticking custom MSBuild project files into their SolutionToBuild item groups.  It may also be useful for building/publishing only a subset of the projects within a solution - the in-memory project file generated by MSBuild for a solution typically includes targets of the form <Project Name>:<Target> (except for the Build target, where the target is just the name of the project).  So - if you wanted to build the project Foo.csproj and publish the project Bar.vbproj, but do nothing with any other projects within MyStandardSolution.sln, you could do something like:

      <SolutionToBuild Include="$(BuildProjectFolderPath)/path/MyStandardSolution.sln">

I'm sure enterprising Team Build users will find other uses for this functionality as well - if you are one of them, please post your examples here!

Comments (6)
  1. Buck Hodges says:

    Aaron Hallberg has a written a great post on one of the new extensibility mechanisms we’ve added to the

  2. First of all, sorry for the long delay between posts… Things have been a bit crazy around here trying

  3. First of all, sorry for the long delay between posts… Things have been a bit crazy around here trying

  4. Code Junkie says:

    For sometime now I have been working on custom MSBuild task. The following links were very useful in

  5. In an earlier post I described how one can, in Orcas, preserve the output directory structure used in

  6. I’ve done a couple of posts now on calling custom targets during a Team Build build – this one focused

Comments are closed.

Skip to main content