Welcome to MSDN Blogs Sign
in | Join
| Help

Manish Agarwal

This Blog

Email

Calendar

Nov

December 2005

Jan

S

M

T

W

T

F

S

27

28

29

30

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

1

2

3

4

5

6

7

Search

Go

Syndication

RSS 2.0

Atom 1.0

Archives

May
2006 (3)

April
2006 (5)

March
2006 (3)

February 2006
(1)

January
2006 (7)

December 2005
(6)

November 2005
(4)

October
2005 (4)

September 2005
(6)

August
2005 (1)

July
2005 (6)

News

All postings in this blog is provided "AS IS" with no warranties,
and confers no rights. The statements and opinions expressed herein are my own
and are not made on behalf of my employer.

Navigation

Home

Photos

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

You can also stay up to date using your favorite aggregator by subscribing to
the CommentRss
Feed

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

http://blogs.msdn.com/manishagarwal/archive/2005/12/22/506635.aspx

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

What do you think?

Title
(required)*

Name required*

Your URL

Comments
(required)*

Remember Me?