是否可以使用TFS API获得所有项目和子项目 [英] Is it possible to get all the projects and subprojects using TFS API

查看:60
本文介绍了是否可以使用TFS API获得所有项目和子项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用TFS API。我正在尝试从TFS获取项目,子项目,文件的完整列表。
有人可以指导我。

I am working on TFS API. I am trying to get the entire list of projects, subprojects, files from TFS. Could someone guide me regarding it.

TfsTeamProjectCollection teamProjectCollection = teamFoundationserver.TfsTeamProjectCollection;
ProjectCollection projCollect = (ProjectCollection) teamProjectCollection.GetService(typeof(ProjectCollection));

上面的代码仅显示了TFS的第一级。我如何才能更深入地了解TFS树。
我想要整个项目列表,以及每个项目下的解决方案

The above code just shows the first level from TFS. How Can I go further deep into TFS tree. I want the entire list of projects, and solutions under each project.

谢谢,
SV

Thanks, SV

推荐答案

没有子项目之类的东西。听起来您想做的就是获取每个项目下所有子文件夹/文件的列表。

There's no such thing as a "subproject." What it sounds like you want to do is get a listing of all subfolders / files under each project.

为此,请遍历每个项目,然后执行每个 GetItems 。这里是一些代码:

To do that, iterate through each of your projects, and do a GetItems on each. Here's some code:

TfsTeamProjectCollection teamProjectCollection = new TfsTeamProjectCollection(new Uri("http://sw100429:8080"));

ProjectCollection projCollect = (ProjectCollection)teamProjectCollection.GetService(typeof(ProjectCollection));

VersionControlServer vcs = teamProjectCollection.GetService<VersionControlServer>();

// This approach lets you get the list of files for each team project individually.

foreach (TeamProject tp in projCollect)
{
    string path = string.Format("$/{0}", tp.Name);
    var filesAndFolders = vcs.GetItems(path, RecursionType.Full);
}


// However, this approach is a bit more succinct - instead
// of getting them for each team project, just start at "$/" and work your way down

var allFilesAndFolders = vcs.GetItems("$/", RecursionType.Full);

这篇关于是否可以使用TFS API获得所有项目和子项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆