前端之家收集整理的这篇文章主要介绍了
c# – 如何从TFS获取构建定义?,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
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;
}
原文链接:https://www.f2er.com/csharp/91703.html