How to Build a Project with Dependencies on Another Team Project

- J.D. Meier, Jason Taylor, Alex Mackman, Prashant Bansode

Team Build does not support building solutions that cross team projects. To enable this, you must customize the TFSBuild.proj file to check out the code you need from the other projects on which your build depends.

To build a project with dependencies on another team project, you need to get the source or assemblies from that project into the workspace on your build server. To do this, you need to edit your TFSBuild.proj file to add the assembly or the solution reference and override the BeforeGet event to get assemblies or sources from each of the team projects on which you have a dependency.

To build a project that has dependencies on another team project
  • Check out the TFSBuild.proj** script from Source Control Explorer.
  • Add the following configuration setting under the PropertyGroup section:
<!-- to be added under PropertyGroup -->
<TfCommand>$(TeamBuildRefPath)\..\tf.exe</TfCommand>
<SkipInitializeWorkspace>true</SkipInitializeWorkspace>

SkipInitializeWorkSpace allows you to skip invoking the default tasks to delete and re-create the workspace on the build machine. The new property is used in the custom target BeforeGet (see below).
  • Add the following configuration setting to the ItemGroup entries that map both the Team Projects and the solutions. Make sure that you provide the correct local paths for the build machine. Multiple mappings cannot share the same local folder and will result in a MappingConflictException exception in the CreateWorkspace task.
<ItemGroup>
  <!-- add one entry for every solution you reference -->
  <SolutionToBuild Include="$(SolutionRoot)\DependentApp\DependentApp.sln" />
  <SolutionToBuild Include="$(SolutionRoot)\YourApp\YourApp.sln" />
</ItemGroup>

<ItemGroup>
  <!-- add one entry for every Team Project you reference -->
  <Map Include="$/YourApp/YourApp">
    <LocalPath>$(SolutionRoot)\YourApp</LocalPath>
  </Map>
  <Map Include="$/DependentApp/DependentApp">
    <LocalPath>$(SolutionRoot)\DependentApp</LocalPath>
  </Map>
</ItemGroup>
  • Override the BeforeGet event to retrieve the workspaces for each Team Project:
<Target Name="BeforeGet">
  <DeleteWorkspaceTask 
      TeamFoundationServerUrl="$(TeamFoundationServerUrl)" 
      Name="$(WorkspaceName)" />
  <Exec 
    WorkingDirectory="$(SolutionRoot)" 
    Command="&quot;$(TfCommand)&quot; workspace /new $(WorkSpaceName) /server:$(TeamFoundationServerUrl)"/>
  <Exec 
   WorkingDirectory="$(SolutionRoot)"
   Command="&quot;$(TfCommand)&quot; workfold /unmap /workspace:$(WorkSpaceName) &quot;$(SolutionRoot)&quot;"/>
  <Exec 
    WorkingDirectory="$(SolutionRoot)" 
    Command="&quot;$(TfCommand)&quot; workfold /map /workspace:$(WorkSpaceName) /server:$(TeamFoundationServerUrl) &quot;%(Map.Identity)&quot; &quot;%(Map.LocalPath)&quot;"/>
</Target> 
  • Check in the build script and run the build.

Additional Resources

Last edited Jul 26, 2007 at 6:57 AM by prashantbansode, version 1

Comments

No comments yet.