Geeks With Blogs

Tim Huffam Dotting the I and crossing the T of I.T.

When creating a branch programmatically using the TFS 2010 API, if you do not do things in the correct sequence, TFS does not create the proper object types and/or relationships eg either the folders will not show as branches (showing the branch icon instead of the folder icon) in Source Control Explorer or they will show as branches, but when you do View Hierarchy, it will not show the relationships/structure.

After much trial an error I have found the solution...

(assuming the source folder already exists)

// The source of the branch must first be created as a branch object
VersionControl.CreateBranchObject(new BranchProperties(new ItemIdentifier(sourceServerPath)));

// Then you can create the branch
VersionControl.CreateBranch(sourceServerPath, targetServerPath, VersionSpec.Latest, null, checkinComment, null, null, null);

That's it!

HTH
Tim

Posted on Thursday, April 19, 2012 10:40 PM C# .NET , ASP.NET , Dev Env, TFS, MSBuild etc | Back to top


Comments on this post: Programmatically create a branch with the TFS 2010 API

# re: Programmatically create a branch with the TFS 2010 API
Requesting Gravatar...
It has been really nice reading about programmatically creating a branch. Thanks for sharing.
Left by visit this site on Oct 24, 2012 12:40 AM

# re: Programmatically create a branch with the TFS 2010 API
Requesting Gravatar...
a few of code, you save my life
Left by tai facebook on Nov 20, 2012 2:18 AM

# re: Programmatically create a branch with the TFS 2010 API
Requesting Gravatar...
programming is not a easy thing to do there are many thing include in it like there various types of coding as well as some script and many more things
Left by mazapoint on Nov 21, 2012 2:44 AM

# re: Programmatically create a branch with the TFS 2010 API
Requesting Gravatar...
I love this site, thanks bro
Left by tai opera mini on Nov 23, 2012 4:17 AM

# re: Programmatically create a branch with the TFS 2010 API
Requesting Gravatar...
Thanks I will check this out. I just started studying IT, so this will be useful.
Left by Maria on Apr 14, 2013 2:01 PM

# re: Programmatically create a branch with the TFS 2010 API
Requesting Gravatar...
Das hat gut bei mir funktioniert, vielen Dank für den Code - thanks for your great help.
Left by Sarah on Apr 29, 2013 8:35 AM

Your comment:
 (will show your gravatar)


Copyright © Tim Huffam | Powered by: GeeksWithBlogs.net | Join free