How can I get the latest change-set number via TFS API

前端 未结 1 1316
长发绾君心
长发绾君心 2021-01-12 16:43

How can I get the latest change-set number via TFS API? Could you give me an example?

相关标签:
1条回答
  • 2021-01-12 16:57

    Here you go:

    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 is invoked with the path in the VersionControl of your TeamProject, we want the history from the latest to the latest changeset, the whole bunch of parameters left are pretty default in your case.

    0 讨论(0)
提交回复
热议问题