开发者

How to get List of projects from TFS?

开发者 https://www.devze.com 2023-01-01 11:02 出处:网络
How do I get list of projects from TFS s开发者_Go百科erver using webservice? Is documentation available for the TFS Webservices?I concur with bryanjonker as well.Don\'t call the webservice directly,

How do I get list of projects from TFS s开发者_Go百科erver using webservice?

Is documentation available for the TFS Webservices?


I concur with bryanjonker as well. Don't call the webservice directly, that's really reserved for internal use. Create your own access layer and call the API.

You can also use the object model to get access to the ICommonStructureService. I've recently started using this, and find it to be cleaner. The code below does the same as bryanjonker's example:

    var tfs = TeamFoundationServerFactory.GetServer(serverUri);

    var projectCollection = tfs.GetService<ICommonStructureService>();

    foreach (var projectInfo in projectCollection.ListProjects())
    {
        listBox1.Items.Add(projectInfo.Name);
    }


Your best bet is to use the TFS DLLs and that API, which is at http://msdn.microsoft.com/en-us/library/bb130146(VS.80).aspx and http://msdn.microsoft.com/en-us/library/bb130334(v=VS.80).aspx . From what I understand, hitting the webservice directly is frowned upon.

To get a list of projects, I think there's multiple ways to do this. I posted code I used: use the GetServer method to get a project collection, then list through the ListProjects() method. I needed to do this because I needed to get the areas and iterations as well. This requires the Microsoft.TeamFoundation.Client namespace.

var tfs = TeamFoundationServerFactory.GetServer(Constants.TEAMFOUNDSERVER);
var projectCollection  = (ICommonStructureService)tfs.GetService(typeof(ICommonStructureService));
foreach (var projectInfo in projectCollection.ListProjects()) 
{
     //do stuff here
}
0

精彩评论

暂无评论...
验证码 换一张
取 消