7

如何通过 TFS API 获取最新的变更集编号?你能给我举个例子吗?

4

1 回答 1

7

干得好:

TeamProjectPicker tpp = new TeamProjectPicker(TeamProjectPickerMode.SingleProject, true);
tpp.ShowDialog();

var tpc = tpp.SelectedTeamProjectCollection;

VersionControlServer versionControl = tpc.GetService<VersionControlServer>();

var tp = versionControl.GetTeamProject("MyTeamProject");
var path = tp.ServerItem;

var q = versionControl.QueryHistory(path, VersionSpec.Latest, 0, RecursionType.Full, null, VersionSpec.Latest, VersionSpec.Latest, Int32.MaxValue, true, true, false, false);

Changeset latest = q.Cast<Changeset>().First();

// The number of the changeset
int id = latest.ChangesetId;

QueryHistory 是使用 TeamProject 的 VersionControl 中的路径调用的,我们想要从最新到最新变更集的历史记录,在您的情况下,剩下的所有参数都是默认的。

于 2012-04-20T19:58:11.667 回答