Reputation: 397
So in my code I have this as the setup for accessing the server item.
var tfs = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://samplerepo:8080/tfs_proj/WindowsMain"), new UICredentialsProvider());
tfs.EnsureAuthenticated();
VersionControlServer vsStore = tfs.GetService<VersionControlServer>();
However when I want to create a workspace based on this server I can't. The reason is that WindowsMain isn't mapped to a local folder. However WindowsMain/MainProject is mapped to a local folder. So how can I create a workspace that is mapped to MainProject. Seeing as I cannot connect to WindowsMain/MainProject just WindowsMain since the way server connections are done with team foundation.
Upvotes: 0
Views: 66
Reputation: 1911
below code updates all files in given project. if you want to compare it could be easily modified:
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);
}
}
}
}
}
you can replace:
vc.DownloadFile(item.SourceServerItem, item.LocalItem);
with Console.WriteLine(item.LocalItem +": needs updating");
Upvotes: 1