如何从 TFS 获取构建定义?
Posted
技术标签:
【中文标题】如何从 TFS 获取构建定义?【英文标题】:How to get build definitions from TFS? 【发布时间】:2013-04-12 16:52:21 【问题描述】:如何使用给定 collection-guid 和 project-name 的 TFS-API 获取构建定义
详情请咨询here。这是关于 TFS 的最佳资源之一。
【问题讨论】:
【参考方案1】:private TfsConfigurationServer configurationServer;
configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(uri);
public IList<KeyValuePair<string, Uri>> GetBuildDefinitionListFromProject(Guid collectionId, string projectName)
List<IBuildDefinition> buildDefinitionList = null;
List<KeyValuePair<string, Uri>> buildDefinitionInfoList = null;
try
buildDefinitionInfoList = new List<KeyValuePair<string, Uri>>();
TfsTeamProjectCollection tfsProjectCollection =
configurationServer.GetTeamProjectCollection(collectionId);
tfsProjectCollection.Authenticate();
var buildServer = (IBuildServer)tfsProjectCollection.GetService(typeof(IBuildServer));
buildDefinitionList = new List<IBuildDefinition>(buildServer.QueryBuildDefinitions(projectName));
catch (Exception e)
ApplicationLogger.Log(e);
if (buildDefinitionList != null && buildDefinitionList.Count > 0)
foreach (IBuildDefinition builddef in buildDefinitionList)
buildDefinitionInfoList.Add(new KeyValuePair<string, Uri>(builddef.Name, builddef.Uri));
return buildDefinitionInfoList;
【讨论】:
TFS 2015 vNext 构建怎么样?以上是关于如何从 TFS 获取构建定义?的主要内容,如果未能解决你的问题,请参考以下文章
如何通过 C# 中的 Release ID 从 TFS 获取测试结果