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">
<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>
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">
<Targets>Foo;Bar:Publish</Targets>
</SolutionToBuild>
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
- Anonymous
August 15, 2007
Aaron Hallberg has a written a great post on one of the new extensibility mechanisms we've added to the - Anonymous
February 08, 2008
The comment has been removed - Anonymous
February 08, 2008
The comment has been removed - Anonymous
April 11, 2008
For sometime now I have been working on custom MSBuild task. The following links were very useful in - Anonymous
April 28, 2008
In an earlier post I described how one can, in Orcas, preserve the output directory structure used in - Anonymous
December 30, 2008
I've done a couple of posts now on calling custom targets during a Team Build build - this one focused