[英]How to get the name of all projects in a TFS collection?
傳入集合guid,列表返回該特定集合中所有項目的名稱。
public IList<string> GetProjectsFormCollection(Guid collectionId)
{
ICommonStructureService structureService = null;
try
{
TfsTeamProjectCollection teamProjectCollection =
_configurationServer.GetTeamProjectCollection(collectionId);
teamProjectCollection.Authenticate();
structureService =
(ICommonStructureService)teamProjectCollection.GetService(typeof(ICommonStructureService));
}
catch (Exception e)
{
ApplicationLogger.Log(e);
}
var projectInfoList = new List<ProjectInfo>(structureService.ListAllProjects());
IEnumerable<string> data = projectInfoList.Select(proj => proj.Name);
List<string> list = data.ToList();
return list;
}
你現在可以通過其余的api做到這一點。 例如
GET https://fabrikam-fiber-inc.visualstudio.com/DefaultCollection/_apis/projects?api-version=1.0
來自: https : //www.visualstudio.com/en-us/docs/integrate/api/tfs/projects
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.