![](/img/trans.png)
[英]How do I get a list of connected TFS projects in Visual Studio?
[英]How to connect with TFS and get list of projects for a specific user
public List<string> ListAllProjects(){
TeamFoundationServer teamFoundationServer =
TeamFoundationServerFactory.GetServer(@"http:\\ld-tfs08sp1:8080\\");
teamFoundationServer.Authenticate();
WorkItemStore workItemStore = new WorkItemStore(@"http:\\ld-tfs08sp1:8080\\");
List<string> list = new List<string>();
foreach (Project pr in workItemStore.Projects)
{
list.Add(pr.Name);
}
if (list.Count == 0)
list.Add("Not Found");
return list;
}
以下示例將檢索TFS 2010中給定團隊項目集(TPC)的團隊項目列表:
static void Main(string[] args)
{
var results = GetTfsProjects(new Uri("http://mytfsserver:8080/tfs/DefaultCollection"));
}
private static List<string> GetTfsProjects(Uri tpcAddress)
{
var tpc = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(tpcAddress);
tpc.Authenticate();
var workItemStore = new WorkItemStore(tpc);
var projectList = (from Project pr in workItemStore.Projects select pr.Name).ToList();
return projectList;
}
希望這可以幫助。
試試這個
var TeamProjectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(teamProjectCollectionUrl);
var commonStruct = TeamProjectCollection.GetService<ICommonStructureService>();
var teamProjectInfos = commonStruct.ListAllProjects();
祝好運
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.