One of Team Build’s behaviors that I often get questions about is it overriding the OutDir property and putting all of the build outputs in a single directory per platform and configuration. The typical reason that people want to split the Team Build outputs is to match how they’ll be deployed, for example, into a “Client” directory, a “WindowsService” directory, and a “WebSite” directory.
There’s a number of solutions to this problem but there’s a very simple one that I’ve used numerous times and have recommended to several people so I wanted to blog it so I can just point people at this post. It won’t work in all scenarios but if it does work in your scenario it’s undoubtedly the easiest solution while still offering some flexibility.
Team Build will create a directory for each platform and configuration pair so we can leverage this to split our outputs by defining solution-level configurations for each split of the outputs we want. Since most people find Configuration useful (to allow switching between Debug and Release) we’ll use Platform to define the different sets of outputs we want.
In the following example I’ll be building a solution containing four projects, “Client”, “Common”, “WebSite”, and “WindowsService”. We’re going to create three folders in the drop, “Client” (containing the outputs from the “Client” and “Common” projects), “WebSite” (containing the outputs from the “WebSite” and “Common” projects), and “WindowsService” (containing the outputs from the “WindowsService” and “Common” projects). I usually also create a platform called “All” containing all projects which is the one developers would select in Visual Studio when working with the solution.
The first thing we need to do is define each of the “platforms” we want to be able to build. To do this:
These screenshots show the Debug and Release configurations for the WindowsService “platform”:
Finally, we need to configure the build definition to build each of our new platforms:
This screenshot shows the Items To Build dialog configured to build the “Client”, “WebSite”, and “WindowsService” “platforms” using Debug and Release configurations:
These screenshots show the resulting drop structure for the “Client” “platform”: