使用此:How can I get the latest change-set number via TFS API
我只能获得团队项目的OLDEST变更集并使用对话窗口。
有人可以举个例子来说明如何: - 以编程方式设置团队项目集合,团队项目和项目? - 获取项目的变更集(不是团队项目集合或团队项目变更集)?
E.g
var TPC = <NameOfTeamProjectCollection>
var TP = <NameOfTeamProject>
var P = Path
类似
TPC = @"$/House"
TP = @"$/Room"
P = @"$Bed/Sheet"
所以最后我会获得目录sheet
的变更集,或者忽略bed
的变更集。
public static int GetChangesetId()
{
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;
return id;
}
我尝试将@"MyTeamProject"
更改为路径但不起作用。我得到一个错误,没有这样的项目。