Working with multiple team projects in Team Build



Building solutions that reference to assemblies belonging to different team project




Assume that we two projects (ConsoleApplication1 and ConsoleApplication2) under team project (TP1) and they are using the assembly (commonlibrary.dll) that is checked in under a different team project (TP2). Let us assume the corresponding paths under version control are






Note: please make sure that you have used File Reference to add the reference for commonlibrary.dll and CopyLocal option is set to true. Otherwise your desktop build scenario will be broken.


Custom steps to enable building the project

  • Create the BuiltType “Type1” for TP2.

  • Check out the Tfsbuild.proj file for “Type1” build type.

  • Reset the following property. This is done to skip invoking the default tasks to delete and recreate workspace on the build machine.


  • Define the new property. This is just for the user convenience and will be used in the custom target “BeforeGet” (mentioned below)


  • Define the folder mappings item group. (You are responsible for giving the correct local paths for the build machine. Please note that multiple mappings can not share the same local folder and will result in MappingConflictException in the CreateWorkspace task. Another recommendation is to avoid mapping to $(SolutionRoot). This is because if while creating workspace, task detects overlapping local paths, it will try to merge the local paths and screw up the relative paths. Please note that I have not explored the cloaking option.


         <Map Include="$/TP2/Main">



         <Map Include="$/TP1/Framework">




  • Override the “BeforeGet” target.

    <Target Name="BeforeGet">   

    <!— to remove any workspace that exist with the same name, from some previous build à



        Name="$(WorkspaceName)" />   



    <!— create the workspace with default mapping that maps $(SolutionRoot) to $/ à



      Command="&quot;$(TfCommand)&quot; workspace /new $(WorkspaceName) /server:$(TeamFoundationServerUrl)"/>



    <!— task will add the folder mappings corresponding to items define in step 5 à



      Command="&quot;$(TfCommand)&quot; workfold /map /workspace:$(WorkSpaceName) /server:$(TeamFoundationServerUrl) &quot;%(Map.Identity)&quot; &quot;%(Map.LocalPath)&quot;"/>



    <!— remove the default mapping ( $(SolutionRoot) ß> $/)that was created initially. Otherwise all the team projects will be synced under the $(SolutionRoot) à  



     Command="&quot;$(TfCommand)&quot; workfold /unmap /workspace:$(WorkSpaceName) &quot;$(SolutionRoot)&quot;"/>




  •  Verify that sln paths (SolutionToBuild itemgroup) for correct relative paths

<SolutionToBuild Include="$(SolutionRoot)\Main\ConsoleApplication1\ConsoleApplication1.sln" />

<SolutionToBuild Include="$(SolutionRoot)\Main\ConsoleApplication2\ConsoleApplication2.sln" />

  • Similarly verify the vsmdi paths (MetaDataFile itemgroup) for correct relative paths.

  • Checkin the tfsbuild.proj file and launch the build.



  • Please make sure that CopyLocal option is set for the file reference.

  • Use File reference to add references for assemblies belonging to different team projects. Sometime these reference paths will be broken because the relative path on the build machine is different from the one mentioned in the csproj file of your project. In such cases you need to specify the correct location of the external assembly. You can easily do it by defining “AdditionalReferencePath” item pointing to the folder containing the assembly.

  • Please try to avoid mapping directly to “$(SolutionRoot)”. Still if your “Map” item group contains any working folder mapping that points to only “$(SolutionRoot)”, then you need to remove the following line from the BeforeGet target :-

<Exec Command="&quot;$(TfCommand)&quot; workfold /unmap /workspace:$(WorkSpaceName) &quot;$(SolutionRoot)&quot;" WorkingDirectory="$(SolutionRoot)"/>   



Other interesting posts on the related/same issue are [post] [post1] [post2] [post3]




Comments (18)
  1. Jeffrey Irwin says:

    Great post!

    I’m having a problem in how to get my test cases to run after running a build. Here’s what I’m trying to do:












    We need to build the Site, and run the Automations in the Test folder, but don’t want to load everything under Project, so we’re trying to selectively include the sections we want.

    As such, I want to include the following Map node in my Build .proj file

    <Map Include="$/Project/Main/Dev/Site">



    <Map Include="$/Project/Main/Test">



    However, doing this causes me to get a OutOfMemoryException after about 5 minutes of the build server trying to get sources. Even when I get rid of the second map element, this happens. In fact, any time I map LocalPath to anything other than “$(SolutionRoot)”, I get the exception. I notice that you have mapped successfully to $(SolutionRoot)Main, do you know why I would be seeing the problems I’m seeing? Thank you very much!


  2. Jeffrey Irwin says:

    Sorry, the above folder structure should show "Project" as highest level. Dev, Test, and Docs should be second level, and everything else is third level.












  3. Manish Agarwal says:


    It looks like you are interested in selectively sync specific folders and not download everything. Moreover I am assuming everything in under same team project. Please check the post for the solution –

    Hope it helps

  4. Jeff Irwin says:

    I’m afraid this didn’t work, at least not what I expected it to do. For example, i added the item

    <InternalMapping ServerItem="$/Project/Site/Main/Docs" Type="Cloak"/>

    Then I checked the sources folder in the build location, and the docs folder was still there, as it was previously. My goal is simply to keep from ‘getting’ folders that arn’t necessary for this build, such as the Docs folder. Am I doing something wrong? Thanks for the help!

  5. One of the challenges we hadn&amp;rsquo;t figured out was how to deal with the case where Team Project B…

  6. AdamJTP says:

    Swap the map and unmap elements in BeforeGet and it works.


  7. Buck Hodges says:

    Last week, the folks at Vertigo Software wrote a couple of really good posts involving Team Build.


  8. Stephen Joseph says:

    Hi Al I have a situation where the reverse order of team projects needs to be compiled in a team build. How do i specify the path for the source project for team project 1 in custom task?

  9. Ian Nelson says:

    I returned to work after Tuesday’s MSDN Roadshow fired up and full of ideas, eager to try out ASP.NET

  10. Michael says:

    Which idiot came up with this?

    You end up with a folder structure 5 levels deep before you get to any files. And you’ve got folders named things like ‘MyWebAppSln’ – why not ‘MyWebApplication’?

    Sorry if this is the wrong place to vent, but the article links to this blog post.

  11. Matt says:

    The solution structure described on MSDN works quite well.  The names don’t matter too much, but the structure copes with 90% of development.

  12. Shai Raiten says:

    Building solutions that reference to assemblies belonging to different team project If you facing the

  13. Futorial says:

    Huaahhh… ini kasus yang umum namun anehnya agak perlu sedikit effort untuk bisa berhasil. Kasus apa sih

  14. Tim Hanson says:

    I am working with several team projects that need assemblies from other team projects. For example,…

  15. jon says:

    I'm looking for SVN functionality of externals properties on folders…. without installing other tools that would have to reside on each developers box.

Comments are closed.

Skip to main content