使用 c# 在 TFS 上获取变更集及其所有更改 [英] Get Changeset and all it's changes on TFS using c#

查看:24
本文介绍了使用 c# 在 TFS 上获取变更集及其所有更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过它的 changesetid 获取特定的变更集.这是工作.问题是我无法获取受该变更集影响的文件.

Changeset changeset = GetChangeset(new Uri("tfs path"), 10918);foreach (var w in changeset.Changes){Console.WriteLine("类型:" + w.ChangeType);Console.WriteLine("Comment:" + changeset.Comment);Console.WriteLine("日期:" + changeset.CreationDate);foreach(在changeset.WorkItems 中变化){Console.WriteLine("名称:" + y.Title + y.Type);}}私有静态变更集 GetChangeset(Uri serveruri, int changesetid){var tfs = new TfsTeamProjectCollection(serveruri);var svc = tfs.GetService();var changeset = svc.GetChangeset(changesetid);返回变更集;}

上面的代码正在运行.我可以将变更集作为对象获取并显示 ChangeTypeCreationDateComment,但我无法获取与更改关联的项目.例如,我编辑了 Program.cs.所以它应该在那个变更集下可见.

如有任何建议,我们将不胜感激.

谢谢!

解决方案

您已经在迭代代码中的更改.受影响的文件位于 Change 类型的 Item 属性中.

在您的情况下:w.Item.ServerItem --> 这是文件的服务器路径,例如 '$/A/B/C.txt'

您可以使用 w.Item.DownloadFile(@"C:local.txt")

下载它

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!

解决方案

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")

这篇关于使用 c# 在 TFS 上获取变更集及其所有更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆