在命令提示符下获取 Tfs Shelveset 文件内容? [英] Get Tfs Shelveset file contents at the command prompt?

查看:12
本文介绍了在命令提示符下获取 Tfs Shelveset 文件内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有兴趣在命令提示符下获取搁置集的内容.现在,您可能会认为 TFS Power Tools 中提供的 Get-TfsShelveset 等 cmdlet 可以执行此操作.您可能还认为tf.exe 搁置集"会这样做.

I'm interested in getting the contents of a shelveset at the command prompt. Now, you would think that a cmdlet such as Get-TfsShelveset, available in the TFS Power Tools, would do this. You might also think that "tf.exe shelvesets" would do this.

但是,除非我遗漏了什么,否则我很震惊地报告这两种情况都不是.相反,每个命令都要求您给它一个搁置集名称,然后简单地反刍该搁置集的单个行项目,以及有关搁置集的一些元数据,例如创建日期、显示名称等.但据我所知,没有办法告诉货架上的实际物品.

However, unless I've missed something, I'm appalled to report that neither of these is the case. Instead, each command requires you to give it a shelveset name, and then simply regurgitates a single line item for that shelveset, along with some metadata about the shelveset such as creationdate, displayname, etc. But as far as I can tell, no way to tell what's actually in the shelf.

这对于 Get-TfsShelveset 来说尤其令人发指,它能够包含一个文件描述符数组以及它返回的 Shelveset 对象.我什至试图变得聪明,认为我可以通过使用 -WhatIf 和 Restore-TfsShelveset 来获取文件名,但遗憾的是,Restore-TfsShelveset 没有实现 -WhatIf.

This is especially heinous for Get-TfsShelveset, which has the ability to include an array of file descriptors along with the Shelveset object it returns. I even tried to get clever, thinking that I could harvest the file names from using -WhatIf with Restore-TfsShelveset, but sadly Restore-TfsShelveset doesn't implement -WhatIf.

请有人告诉我我错了!

推荐答案

可以构建一个使用 TFS SDK 的小型命令行应用程序,该应用程序返回给定搁置集中包含的文件列表.
下面的示例假定了解 Shelveset name &它的所有者:

It is possible to construct a small command-line application that uses the TFS SDK, which returns the list of files contained in a given shelveset.
The sample below assumes knowledge of the Shelveset name & it's owner:

using System;
using System.IO;
using System.Collections.ObjectModel;
using Microsoft.TeamFoundation.Client;
using Microsoft.TeamFoundation.Framework.Common;
using Microsoft.TeamFoundation.Framework.Client;
using Microsoft.TeamFoundation.VersionControl.Client;

namespace ShelvesetDetails
{
    class Program
    {
        static void Main(string[] args)
        {
            Uri tfsUri = (args.Length < 1) ? new Uri("TFS_URI") : new Uri(args[0]);

            TfsConfigurationServer configurationServer = TfsConfigurationServerFactory.GetConfigurationServer(tfsUri);

            ReadOnlyCollection<CatalogNode> collectionNodes = configurationServer.CatalogNode.QueryChildren(
                new[] { CatalogResourceTypes.ProjectCollection },
                false, CatalogQueryOptions.None);

            CatalogNode collectionNode = collectionNodes[0];

            Guid collectionId = new Guid(collectionNode.Resource.Properties["InstanceId"]);
            TfsTeamProjectCollection teamProjectCollection = configurationServer.GetTeamProjectCollection(collectionId);

            var vcServer = teamProjectCollection.GetService<VersionControlServer>();

            Shelveset[] shelves = vcServer.QueryShelvesets(
                "SHELVESET_NAME", "SHELVESET_OWNER");
            Shelveset shelveset = shelves[0];

            PendingSet[] sets = vcServer.QueryShelvedChanges(shelveset);
            foreach (PendingSet set in sets)
            {
                PendingChange[] changes = set.PendingChanges;
                foreach (PendingChange change in changes)
                {
                    Console.WriteLine(change.FileName);
                }
            }
        }
    }
}

调用这个控制台应用程序 &在执行 PowerShell 期间捕获结果应该是可能的.

Invoking this console app & catching the outcome during execution of the powershell should be possible.

这篇关于在命令提示符下获取 Tfs Shelveset 文件内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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