获取包含完整目录结构的TFS中更改列表中文件的文件夹/ zip

时间:2012-03-12 14:43:59

标签: deployment tfs

我们的团队使用TFS管理以下流程中的工作流程: 工作项目 - >源控制 - > changelist - >手动部署到服务器

有没有办法获得具有完整目录结构的文件列表给定的更改列表?理想情况下,我希望能够选择多个更改列表和/或工作项以获取与工作项关联的所有更改列表,并获取更改列表/工作项中文件的完整目录结构。

任何建议都将不胜感激,谢谢!

1 个答案:

答案 0 :(得分:0)

您可以使用以下代码段开始

Uri tfsUri = new Uri(@"http://server:8080/tfs");
string serverPath = @"$/Project";

//Connect to the project collection
var projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(
        tfsUri, new UICredentialsProvider());

//Get the source code control service. 
var sourceControl = projectCollection.GetService<VersionControlServer>();
var history = sourceControl.QueryHistory(
    serverPath,  //Source control path to the item. Like $/Project/Path ...
    LatestVersionSpec.Instance, //Search latest version
    0, //No unique deletion id. 
    RecursionType.Full, //Full recursion on the path
    null, //All users 
    new  ChangesetVersionSpec("9829"), //From the 7 days ago ... 
    LatestVersionSpec.Instance, //To the current version ... 
    Int32.MaxValue, //Include all changes. Can limit the number you get back.
    true, //Include details of items, not just metadata. 
    false //Slot mode is false. 
    );

//Enumerate of the changesets. 
foreach (Changeset changeset in history.OfType<Changeset>().Take(1))
{
    foreach (var change in changeset.Changes)
    {
        change.Item.ServerItem.Dump();
    }
}