Skip to content

Instantly share code, notes, and snippets.

@aaronpowell
Created November 28, 2012 05:37
Show Gist options
  • Save aaronpowell/4159243 to your computer and use it in GitHub Desktop.
Save aaronpowell/4159243 to your computer and use it in GitHub Desktop.
Get changeset from workspace
var localPath = "Some Path";
if (!Workstation.Current.IsMapped(localPath)) {
Log.LogError(string.Format("The local path '{0}' is not mapped to a TFS workspace.", LocalPath));
return false;
}
var info = Workstation.Current.GetLocalWorkspaceInfo(localPath);
var collection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(info.ServerUri);
var workspace = info.GetWorkspace(collection);
var localVersions = workspace.GetLocalVersions(new [] {new ItemSpec(localPath, RecursionType.Full)}, false);
var changeset = localVersions[0].Max(v => v.Version);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment