下面的代碼更新給定項目中的所有文件。如果要比較它可以很容易地修改:
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");
正是你正在嘗試做的? – Claudius
@Claudius試圖創建與本地文件夾對應的工作區,以便我可以將工作區版本與服務器版本進行比較,並確定本地解決方案是否與服務器版本相同 – trinityalps
並且您正在討論WindowsMain/MainProject – Claudius