因此,在我的代码中,我将此作为访问服务器项的设置。
var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://samplerepo:8080/tfs_proj/WindowsMain"), new UICredentialsProvider());
tfs.EnsureAuthenticated();
VersionControlServer vsStore = tfs.GetService<VersionControlServer>();
但是,当我想基于此服务器创建工作区时,我不能。原因是WindowsMain未映射到本地文件夹。但是,WindowsMain / MainProject映射到本地文件夹。那么如何创建映射到MainProject的工作空间。因为我无法连接到WindowsMain / MainProject只是WindowsMain,因为服务器连接是通过团队基础完成的。
答案 0 :(得分:1)
下面的代码更新给定项目中的所有文件。如果你想比较它可以很容易修改:
private static void GetLatest(string username, string password, string path_to_download,
string tf_src_path)
{
Uri collectionUri = new Uri(PathConstants.uri);
NetworkCredential credential = new NetworkCredential(username, password);
TfsTeamProjectCollection tfs = new TfsTeamProjectCollection(new Uri(PathConstants.uri), credential);
tfs.EnsureAuthenticated();
VersionControlServer vc = tfs.GetService<VersionControlServer>();
foreach (Workspace workspace in vc.QueryWorkspaces(null, null, System.Environment.MachineName))
{
foreach (WorkingFolder folder in workspace.Folders)
{
ItemSpec itemSpec = new ItemSpec(folder.ServerItem, RecursionType.Full);
ItemSpec[] specs = new ItemSpec[] { itemSpec };
ExtendedItem[][] extendedItems = workspace.GetExtendedItems(specs, DeletedState.NonDeleted, ItemType.File);
ExtendedItem[] extendedItem = extendedItems[0];
foreach (var item in extendedItem)
{
if (item.VersionLocal != item.VersionLatest)
{
vc.DownloadFile(item.SourceServerItem, item.LocalItem);
}
}
}
}
}
你可以替换:
vc.DownloadFile(item.SourceServerItem, item.LocalItem);
Console.WriteLine(item.LocalItem +": needs updating");