要Rename or move files and folders in TFVC,您必须是贡献者为团队项目之一。见Team Foundation Server default groups, permissions, and roles。
我测试了一下,并用“PendRename
”方法正确地重命名了分支。
下面的代码示例,供您参考:
using System;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;
namespace RenameBranch
{
class Program
{
static void Main(string[] args)
{
string oldPath = @"E:\andy\0418Scrum\web0418-0823";
string newPath = @"E:\andy\0418Scrum\web0418-1020";
string collection = @"http://server:8080/tfs/DefaultCollection";
var tfsServer = new Uri(collection);
var tpc = new TfsTeamProjectCollection(tfsServer);
var vcs = tpc.GetService<VersionControlServer>();
Workspace workspace = vcs.GetWorkspace("YourWorkspaceName", vcs.AuthorizedUser);
workspace.PendRename(oldPath, newPath);
}
}
}
然后,你需要签入,当然它。使用“workspace.GetPendingChanges()”和“workspace.CheckIn()”方法来完成它。