Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Changeset and all it's changes on TFS using c#

Tags:

c#

tfs

I am trying to get a specific changeset by it's changesetid. It is working. The problem is I can't get the files affected by that changeset.

Changeset changeset = GetChangeset(new Uri("tfs path"), 10918);

foreach (var w in changeset.Changes)
{
    Console.WriteLine("Type:" + w.ChangeType);
    Console.WriteLine("Comment:" + changeset.Comment);
    Console.WriteLine("Date:" + changeset.CreationDate);

    foreach (var y in changeset.WorkItems)
    {
        Console.WriteLine("Name:" + y.Title + y.Type);
    }
}

private static Changeset GetChangeset(Uri serveruri, int changesetid)
{
    var tfs = new TfsTeamProjectCollection(serveruri);
    var svc = tfs.GetService<VersionControlServer>();
    var changeset = svc.GetChangeset(changesetid);

    return changeset;
}

The above code is working. I can get the changeset as an object and display the ChangeType, CreationDate and Comment but I can't get the items associated with the change. For example, I edited the Program.cs. So it should be visible under that changeset.

Any suggestion would be gladly appreciated.

Thanks!

like image 747
Gerald Avatar asked Feb 04 '14 06:02

Gerald


1 Answers

You are already iterating over the Changes in your code. The affected File is in the Item property of the Change type.

in your case: w.Item.ServerItem --> This is the Serverpath of the File like '$/A/B/C.txt'

You can download it by using w.Item.DownloadFile(@"C:\local.txt")

like image 147
Scordo Avatar answered Sep 23 '22 09:09

Scordo