TFS 2008: Calling custom targets and documentation for the beta 2 object model
Aaron Hallberg has a written a great post on one of the new extensibility mechanisms we’ve added to the Microsoft.TeamFoundation.Build.targets file that forms the backbone of the msbuild process (it’s imported by every tfsbuild.proj file and contains all of the targets and properties). Aaron shows you how to have a different target called for each of the projects and solutions that you build, which allows for greater flexibility in hour your projects and solutions are built.
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"> <Targets>Publish</Targets> </SolutionToBuild> <SolutionToBuild Include="$(BuildProjectFolderPath)/path/MyStandardSolution.sln"> <!-- <Targets>Build</Targets> --> </SolutionToBuild> <SolutionToBuild Include="$(BuildProjectFolderPath)/path/MyCustomProject.proj"> <Targets>SomeTarget;SomeOtherTarget</Targets> </SolutionToBuild>
By the way, even though the word “solution” appears in the name “SolutionToBuild,” you can specify project files as well (e.g., foo.csproj). It doesn’t have to be a solution (we’ve kept the name “SolutionToBuild” from v1 for compatibility and because “SolutionOrProjectToBuild” just seemed like overkill).
Aaron has also posted a new CHM file that contains the documentation for the Orcas beta 2 Team Build object model: Orcas Beta 2 Object Model Documentation. If you want to use the new API, you’ll want this documentation file.