How to Create a Team Build for a Project That References Assemblies from Another Project

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

To build a project that has 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 in order to add the assembly or the solution reference and override the BeforeGet event to get assemblies or sources from each of the required team projects.

To build a project that references assemblies in 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 7:13 AM by prashantbansode, version 1

Comments

No comments yet.