如何通过TFS API获取最新的更改集号? 你能举个例子吗?
答案 0 :(得分: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;
使用TeamProject的VersionControl中的路径调用QueryHistory,我们希望从最新的变更集到最新的变更集,在您的情况下,剩下的一大堆参数都是默认的。