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

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

问题描述

我有兴趣在命令提示符下获取shelveset的内容。现在,你会认为一个小命令,如Get-TfsShelveset,在TFS电动工具,可以做到这一点。你也可能认为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.

但是,除非我错过了一些东西,我很震惊地报告,这两种情况都不是这样。相反,每个命令要求您给它一个shelveset名称,然后简单地反射该搁板集的单个行项目,以及关于搁置集的一些元数据,如creationdate,displayname等。但是据我所知,没有办法来告诉实际在货架上有什么。

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中包含的文件的列表。

下面的示例假定知道Shelveset名称&它的所有者:

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);
                }
            }
        }
    }
}


$ b b

调用此控制台应用程序&在执行powershell期间捕获结果应该是可能的。

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

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

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