Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Executable Utility to get file list changed in a particular changeset

0.00/5 (No votes)
5 Sep 2018 2  
c#, TFS, Get ChangeSet Files , Executable Utility

Introduction

The Executable gets the files from the TFS and gives the list in the console or in a text file

Background

Microsoft TFS application and any sidekick utilities didnt have the feature of copy pasting or exporting the list of files in a particular changeset. Though there are tfpt command line tools, this doesnt give the list as a dump.

Using the code

We need to have a simple poco class with a reference to the Nuget package

Microsoft.TeamFoundationServer.Client 15.112.1

Microsoft.TeamFoundationServer.ExtendedClient 15.112.1

 I have used Visual Studio 2015

using System;
using System.Collections.Generic;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.VersionControl.Client;

namespace TFSGetChangeset
{
    class Program
    {  
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                System.Console.WriteLine("Please enter arguments.");
               
            }
             
            TfsTeamProjectCollection tpc = new TfsTeamProjectCollection(new Uri("http://tfspathtotheCollection"));
            string path = args[0];
            new System.Net.NetworkCredential(args[1], args[2]);
            tpc.EnsureAuthenticated();
            VersionControlServer vcs = tpc.GetService<VersionControlServer>();
            List<string> files = new List<string>();
            int cid = vcs.GetLatestChangesetId();
            
            var history = vcs.QueryHistory(path, RecursionType.Full, 10);
            Console.WriteLine("********************************************");

            Changeset changeset = vcs.GetChangeset(Convert.ToInt32(args[3]));

            if (changeset.Changes != null)
            {
                foreach (var changedItem in changeset.Changes)
                {
                    string item = changedItem.Item.ServerItem;
                    if (!files.Contains(item))
                    {
                        files.Add(item);
                        Console.WriteLine(item);
                    }
                }
            }
            Console.WriteLine("********************************************");
            Console.ReadLine();
          
              
        }
      

    }
}

 Usage:

tfspathtotheCollection in the code needs to be replaced accordingly

Compile the Project and execute the same as below in the application path from the command line

say: C:\applicationpath:

TFSGetChangeset.exe "$tfspath/branchname" "domain\\user" "password" changesetid >> Outputflle.txt

 

The file Outputflle.txt will have the list of files changes in the changeset.

Points of Interest

Yes, it served my need and got to explore a new library

History

This can be further enhanced as per future requirements, one is to have it implemented for multiple changesets and dump it to text file.

 

The Code has been compiled based on few microsoft code references from web and compiled in to a Utility as per my requirement. Hope it serves others purpose too.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here