are there any API to get the only changed files incrementally? RRS feed

  • Question

  • I know we can use tf get /preview to get the list of changed files, but are there any API to get the real changed files (not just the list) and copy those changed files to the other folder?

    Tuesday, November 25, 2014 3:15 AM


  • Hi Juice_li,

    To get the list of changed files, you could use Microsoft.TeamFoundation.VersionControl.Client namespace to get the changeset, use the changeset to retrieve the changed files list. With the files list you can download them from the version control server: Check this code sample to get the change set information with TFS API:

    using Microsoft.TeamFoundation.Client;
    using Microsoft.TeamFoundation.Server;
    using Microsoft.TeamFoundation.VersionControl.Client;
    public void GetChangesetsInfo()
                TfsTeamProjectCollection proj_coll = new TfsTeamProjectCollection(new Uri("http://NvnTfsserver:8080/tfs/defaultcollection/"), new System.Net.NetworkCredential(username, password));
                VersionControlServer vcs = (VersionControlServer)proj_coll.GetService(typeof(VersionControlServer));
                //Following will get all changesets since 20 days. Note : "DateVersionSpec(DateTime.Now - TimeSpan.FromDays(20))"
                System.Collections.IEnumerable history = vcs.QueryHistory("$/Stakeholders Test Project", LatestVersionSpec.Instance, 0, RecursionType.Full, null, new DateVersionSpec(DateTime.Now - TimeSpan.FromDays(20)), LatestVersionSpec.Instance, Int32.MaxValue, false, false);
                foreach (Changeset changeset in history)
                    Console.WriteLine("Changeset Id: " + changeset.ChangesetId);

    This article tells you how to download the files:

    Team Foundation Server API: Programmatically Downloading Files From Source Control

    For more information, please check this MSDN blog post:

    Team Foundation Version Control client API example for TFS 2010 and newer

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Caillen Monday, December 1, 2014 2:19 AM
    Wednesday, November 26, 2014 7:16 AM