Team System Developer Center >
Visual Studio Team System Forums
>
Team Foundation Server – Power Tools & Add-ons
>
How to get changeset number from TFS 2008
How to get changeset number from TFS 2008
- Dear I want to get the code from source control by using changeset numbers in TFS 2008. I want to know if any utility or source code is available so that I can easily develop or use existed code of utility. Actually I have some requirements related to get the changeset which are developer mark in TFS source Code.
I need to develop utility by using following requirements.
TFS Server Name (for establishing a connection)
TFS User Name
TFS password
TFS Team Project Name
Changeset #
The utility have a button "Get source code" that will get only those files that are being checked in under a changeset #.
If anybody have this kind of utility or have any idea agaist it. Please let me know or help me.
Thanks
M Waseem Alvi
Software Configuration Management Engineer
Answers
- This will get you the TFS and VC server objects. From there use a ChangesetVersionSpec to access the items. You will need to decide how you want to down load the items. You can create a workspace and do a get, or you can query the items and do a item.downloadfile().
NetworkCredential networkCredential = new NetworkCredential("username", "password", "domain"); ICredentials credential = (ICredentials)networkCredential; TeamFoundationServer server = new TeamFoundationServer("http://servername:8080", credential); VersionControlServer vcServer = (VersionControlServer)server.GetService(typeof(VersionControlServer));
- Marked As Answer byRuiz YiModeratorMonday, November 02, 2009 5:05 AM
- Hi Waseem,
As David mentioned, you can create a workspace or just download the files.
Way1: Create a workspace and then get
try { VersionControlServer.GetWorkspace(spacename, "usermane"); VersionControlServer.DeleteWorkspace(spacename, "username"); } catch { } Changeset changeset = VersionControlServer.GetChangeset(changesetID); Workspace ws = VersionControlServer.CreateWorkspace(spacename); ws.CreateMapping(new WorkingFolder("$/TFSProject1/",@"D:\workspace")); ws.Get(changeset.Changes.Select(c=>c.Item.ServerItem).ToArray(), new ChangesetVersionSpec(changesetID),RecursionType.Full, GetOptions.None);
Way2 Just DownLoad Files, but you need to create the path.
Changeset changeset = TFSModal.Instance.VersionControlServer.GetChangeset(changesetID); foreach (var change in changeset.Changes) { change.Item.DownloadFile("path"); }
Best Regards,
Ruiz
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Sincerely, Ruiz Yi- Marked As Answer byRuiz YiModeratorMonday, November 02, 2009 5:05 AM
All Replies
- This will get you the TFS and VC server objects. From there use a ChangesetVersionSpec to access the items. You will need to decide how you want to down load the items. You can create a workspace and do a get, or you can query the items and do a item.downloadfile().
NetworkCredential networkCredential = new NetworkCredential("username", "password", "domain"); ICredentials credential = (ICredentials)networkCredential; TeamFoundationServer server = new TeamFoundationServer("http://servername:8080", credential); VersionControlServer vcServer = (VersionControlServer)server.GetService(typeof(VersionControlServer));
- Marked As Answer byRuiz YiModeratorMonday, November 02, 2009 5:05 AM
- Hi Waseem,
As David mentioned, you can create a workspace or just download the files.
Way1: Create a workspace and then get
try { VersionControlServer.GetWorkspace(spacename, "usermane"); VersionControlServer.DeleteWorkspace(spacename, "username"); } catch { } Changeset changeset = VersionControlServer.GetChangeset(changesetID); Workspace ws = VersionControlServer.CreateWorkspace(spacename); ws.CreateMapping(new WorkingFolder("$/TFSProject1/",@"D:\workspace")); ws.Get(changeset.Changes.Select(c=>c.Item.ServerItem).ToArray(), new ChangesetVersionSpec(changesetID),RecursionType.Full, GetOptions.None);
Way2 Just DownLoad Files, but you need to create the path.
Changeset changeset = TFSModal.Instance.VersionControlServer.GetChangeset(changesetID); foreach (var change in changeset.Changes) { change.Item.DownloadFile("path"); }
Best Regards,
Ruiz
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Sincerely, Ruiz Yi- Marked As Answer byRuiz YiModeratorMonday, November 02, 2009 5:05 AM


