How do i get the 'branch' icon to display in TFS 2013 Source Control when using the TFS API?

StackOverflow https://stackoverflow.com/questions/20600385

  •  02-09-2022
  •  | 
  •  

質問

While experimenting with the TFS 2013 API, I ran into the following issue which I can't seem to resolve when programmatically creating a new branch like this:

//var workspace = connect-to-tfs-server-and-locate-workspace

workspace.PendBranch(scmSourcePath, scmTargetPath, VersionSpec.Latest);
changes = workspace.GetPendingChanges();
workspace.CheckIn(changes, "I just create a branch");

or even via,

workspace.CreateBranch(scmSourcePath, scmTargetPath);

The branch is created just fine, however the new icon featured here http://msdn.microsoft.com/en-us/library/ms181425.aspx is not displayed (notice the alternative icon in the image at FeatureTeamA). Instead the 'uninformative' folder icon is shown.

If i create the same branch using the Source Control Explorer it does show the new 'branch icon'. Anybody any ideas what I'm missing?

役に立ちましたか?

解決

You need to convert the parent folder to BrancObject if it isn't one yet:

// 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);

See also:

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top