问题描述
我想知道是否有对我来说是列出所有文件在TFS团队项目containted的一种方式。什么我的目标做的是寻找那不有固定造成的分支($ / MyTeamProject /主/编译/ instruction.xml和$ / MyTeamProject /分支/ Release_1.0)内TFS路径的特定名称的文件。一旦文件会被发现,我想操纵它。
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.
我想,我们所谈论的项目,当涉及到一个团队项目中containted实体,而不是传统的文件,因此这可能是一个有点棘手?
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的code的升级。该TeamFoundationServer类是在2011年已过时(不知道什么时候发生这种情况,我只知道这是过时截至目前)。 Vengafoo的code是从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团队项目的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!