Welcome to MSDN Blogs Sign in | Join | Help

Working with multiple team projects in Team Build

 

 

Building solutions that reference to assemblies belonging to different team project

 

Scenario

 

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

 

$/TP1/Framework/Common/v2.0/commonlibrary.dll

$/TP2/Main/ConsoleApplication1/ConsoleApplication1.sln

$/TP2/Main/ConsoleApplication1/ConsoleApplication1.sln

 

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.

<SkipInitializeWorkspace>true</SkipInitializeWorkspace>

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

<TfCommand>$(TeamBuildRefPath)\..\tf.exe</TfCommand>

  • 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.

<ItemGroup>

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

             <LocalPath>$(SolutionRoot)\Main</LocalPath>

         </Map>

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

             <LocalPath>$(SolutionRoot)\Framework</LocalPath>

         </Map>

    </ItemGroup>

  • Override the “BeforeGet” target.

    <Target Name="BeforeGet">   

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

    <DeleteWorkspaceTask

        TeamFoundationServerUrl="$(TeamFoundationServerUrl)"

        Name="$(WorkspaceName)" />   

   

 

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

    <Exec

      WorkingDirectory="$(SolutionRoot)"

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

 

   

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

    <Exec

      WorkingDirectory="$(SolutionRoot)"

      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) à  

    <Exec

     WorkingDirectory="$(SolutionRoot)"

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

 

    </Target>

 

  •  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.

 

Recommendations

  • 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)"/>   

References

 

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

 

 

 

Published Thursday, December 22, 2005 11:20 AM by ManishAgarwal

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# re: Working with multiple team projects in Team Build

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:

Project
|--Dev
|--Site
|--UnitTests
|--Docs
|--Tools
|--Test
|--Automations
|--Docs
|--TRD
|--Spec

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">
<LocalPath>$(SolutionRoot)\Site</LocalPath>
</Map>
<Map Include="$/Project/Main/Test">
<LocalPath>$(SolutionRoot)\Test</LocalPath>
</Map>

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!

-Jeff
Wednesday, February 01, 2006 3:58 PM by Jeffrey Irwin

# re: Working with multiple team projects in Team Build

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.

Project
|--Dev
|---|--Site
|---|--UnitTests
|---|--Docs
|---|--Tools
|--Test
|---|--Automations
|--Docs
|---|--TRD
|---|--Spec
Wednesday, February 01, 2006 4:01 PM by Jeffrey Irwin

# re: Working with multiple team projects in Team Build

Jeff,

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 -
http://blogs.msdn.com/manishagarwal/archive/2005/10/13/480584.aspx

Hope it helps

Thursday, February 02, 2006 3:57 AM by Manish Agarwal

# re: Working with multiple team projects in Team Build

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!
Friday, February 03, 2006 7:33 PM by Jeff Irwin

# re: Working with multiple team projects in Team Build

Wednesday, April 05, 2006 11:38 AM by tuan

# Team Build - Referencing other Team Projects

One of the challenges we hadn&amp;rsquo;t figured out was how to deal with the case where Team Project B...
Sunday, May 21, 2006 2:27 AM by MrDave's (David Yack) Blog!

# BeforeGet

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

See:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=367208&SiteID=1
Thursday, July 20, 2006 12:49 PM by AdamJTP

# Two good posts: Building projects with shared code and using Web Application Projects (WAP)

Last week, the folks at Vertigo Software wrote a couple of really good posts involving Team Build.
The...
Tuesday, August 29, 2006 8:09 AM by Buck Hodges

# re: Working with multiple team projects in Team Build

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?

Saturday, March 10, 2007 11:19 AM by Stephen Joseph

# Team Foundation Server - Sharing Binaries and Class Libraries Across Multiple Projects

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

Saturday, March 17, 2007 6:53 PM by Ian Nelson

# re: Working with multiple team projects in Team Build

Which idiot came up with this?

http://msdn2.microsoft.com/en-us/library/bb668986.aspx

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.

Wednesday, April 02, 2008 9:40 AM by Michael

Leave a Comment

(required) 
required 
(required) 
 
Page view tracker