Manish Agarwal has posted a very good tip on how to use Team Build to work with multiple Team Projects. You see, Team Build 1.0 workspace mappings don't support getting the latest version of multiple Team Projects. As a workaround, Manish suggests (see his post for details on each of these steps):
- Skipping the automatic workspace initialisation
- Defining the Team Projects for which you want to get the latest in an Item Group
- Manually initialising the workspace for each of the Team Projects by overriding the "BeforeGet" target
This works fine when your Team Projects are mapped to separate root folders. But as it happens the setup I am working with is slightly different than the one described by Manish. Both Team Projects map to the same folder, and I have a single solution which includes both projects:
$/TP1/Framework maps to $(SolutionRoot)\TP2\WebApplication1
$/TP2/WebApplication1/Portal maps to $(SolutionRoot)\TP2\WebApplication1\Portal
This happens because my framework is a web application itself, and it's used by other projects in a similar way. Now, I know this is probably not the smartest project setup I could have but I had to make it work nonetheless and not worry about having to do a big re-factor of any kind.
I tried to do the following:
<ItemGroup>
<Map Include="$/TP1/Framework">
<LocalPath>$(SolutionRoot)\WebApplication1</LocalPath>
</Map>
<Map Include="$/TP2/WebApplication1/Portal">
<LocalPath>$(SolutionRoot)\WebApplication1\Portal</LocalPath>
</Map>
</ItemGroup>
But my problem was that both Team Projects were being mapped to the same folder. This caused the creation of workspaces within the "BeforeGet" target to delete all contents of my folder before getting the latest version of each project which meant that after getting latest I only had the source code for TP2!
A very simple workaround was:
Slightly modify the mapping so that each Team Project was mapped to a different folder:
<ItemGroup>
<Map Include="$/TP1/Framework">
<LocalPath>$(SolutionRoot)\WebApplication1</LocalPath>
</Map>
<Map Include="$/TP2/WebApplication1/Portal">
<LocalPath>$(SolutionRoot)\WebApplication1_TEMP</LocalPath>
</Map>
</ItemGroup>
Override the "AfterGet" target to do a simple recursive copy from the temporary folder into the proper location:
<!-- Creates a list with all files in the temporary folder -->
<ItemGroup>
<TempFolderContents Include="$(SolutionRoot)\WebApplication1_TEMP\**\*.*" />
</ItemGroup>
<!-- Recursively copies all files into $(SolutionRoot)\WebApplication1\Portal -->
<Target Name="AfterGet">
<Copy SourceFiles="@TempFolderContents"
DestinationFolder="$(SolutionRoot)\WebApplication\Portal\%(RecursiveDir)" />
</Target>