如何使用 tfs api 列出团队项目的文件? [英] How to list files of a team project using tfs api?

查看:21
本文介绍了如何使用 tfs api 列出团队项目的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有办法列出 tfs 团队项目中包含的所有文件".我的目标是搜索特定名称的文件,这些文件在 TFS 中没有由分支引起的固定路径($/MyTeamProject/Main/Build/instruction.xml 和 $/MyTeamProject/Branches/Release_1.0).一旦找到一个文件,我想操纵它.

I am wondering if there is a way for me to list all 'files' containted in a tfs team project. What I am aiming to do is search for files of a particular name that dont have fixed paths within TFS caused by branching ($/MyTeamProject/Main/Build/instruction.xml and $/MyTeamProject/Branches/Release_1.0). Once a file would be found I would like to manipulate it.

我想我们谈论的是团队项目中包含的实体而不是传统文件时的项目,因此这可能有点棘手?

I guess that we are talking items when it comes to entities containted within a team project and not traditional files and therefore this might be a bit tricky?

我看过一些用于操作文件的示例,但到目前为止所有示例都具有固定路径.

I have seen some samples for manipulating a file but all samples so far have fixed paths.

推荐答案

这不是一个不同的答案,而只是 Vengafoo 代码的升级.TeamFoundationServer 类在 2011 年已过时(不确定何时发生,我只知道它现在已过时).Vengafoo 的代码来自 2009 年,所以这是有道理的.将 TfsTeamProjectCollection 类与 TfsTeamProjectCollectionFactory 工厂类一起使用.

This is not a different answer, but simply an upgrade of Vengafoo's code. The TeamFoundationServer class is obsolete in 2011 (not sure when this happened, I just know it is obsolete as of now). Vengafoo's code is from 2009, so that makes sense. Use the TfsTeamProjectCollection class with the TfsTeamProjectCollectionFactory factory class instead.

这是升级,只有一行更改:

Here is the upgrade, just one line of change:

//TeamFoundationServer server = new TeamFoundationServer("server");
TfsTeamProjectCollection server = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(new Uri("http://tfsServerURI:8080/tfs/"));

VersionControlServer version = server.GetService(typeof(VersionControlServer)) as VersionControlServer;

ItemSet items = version.GetItems(@"$\ProjectName", RecursionType.Full);
//ItemSet items = version.GetItems(@"$\ProjectName\FileName.cs", RecursionType.Full);

foreach (Item item in items.Items)
{
    System.Console.WriteLine(item.ServerItem);
} 

这篇关于如何使用 tfs api 列出团队项目的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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