如何通过TFS API获取最新的更改集编号

ora*_*nge 7 c# api tfs

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

Noc*_*ock 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;
Run Code Online (Sandbox Code Playgroud)

使用TeamProject的VersionControl中的路径调用QueryHistory,我们想要从最新的变更集到最新的变更集,在你的情况下,剩下的一大堆参数都是默认的.

  • 我总是得到一个空的可枚举:( (4认同)