在TFS 2010中,我的工作项带有链接的变更集。我可以生成一个查询,以报告正在寻找的工作项。现在,我要查询工作项和直接链接,其中包括链接到这些工作项的所有变更集。在查询编辑器中,我找不到任何将变更集指定为链接项的方法。工作项是查询唯一可能的输出吗?
最佳答案
一种选择是使用TFS API,如以下代码片段所示。
var projectCollection = new TfsTeamProjectCollection(
new Uri("http://localhost:8080/tfs"),
new UICredentialsProvider());
projectCollection.EnsureAuthenticated();
var workItemStore = projectCollection.GetService<WorkItemStore>();
var versionControlServer = projectCollection.GetService<VersionControlServer>();
var artifactProvider = versionControlServer.ArtifactProvider;
var project = workItemStore.Projects["Test01.MSFAgile.v5"];
var teamQueryFolder = project.QueryHierarchy["Team Queries"] as QueryFolder;
var query = teamQueryFolder["My Tasks"];
var queryDefinition = workItemStore.GetQueryDefinition(query.Id);
var variables = new Dictionary<string, string>
{
{"project", query.Project.Name}
};
var workItemCollection = workItemStore.Query(
queryDefinition.QueryText,
variables);
foreach (WorkItem workItem in workItemCollection)
{
Console.WriteLine("WI: {0}, Title: {1}", workItem.Id, workItem.Title);
foreach (var changeset in
workItem.Links
.OfType<ExternalLink>()
.Select(link => artifactProvider
.GetChangeset(new Uri(link.LinkedArtifactUri))))
{
Console.WriteLine(
"CS: {0}, Comment: {1}",
changeset.ChangesetId,
changeset.Comment);
}
}
关于hyperlink - 如何在TFS中查询工作项及其链接的变更集?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5956570/