c# - TFS 自定义构建模板 - 获取不带 Uri 的团队项目集合

标签 c# tfs

是否可以从 IBuildDefinition 或其他相关“服务”获取集合 URI。

我试图避免必须将 URI 作为自定义参数提供给构建模板中的集合。我正在寻找一种方法(在本例中)从 UITypeEditor 自定义类中以编程方式检索它。

有没有一种方法可以在不诉诸硬编码的情况下查询此内容?在我看来,构建过程本身(定义、 Controller 、代理等)知道它们正在处理哪个集合,但我怎样才能找到?

更新:以下是从 UITypeEditor 继承时的示例代码。然后,您只需访问 VersionControlServiceTeamProjectCollection 属性即可:

public class Editor : UITypeEditor
{
    public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
    {           
        if (provider != null)
        {
            IWindowsFormsEditorService service = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));

            if (service != null)
            {                       
                VersionControlServer vcs = provider.GetService(typeof(VersionControlServer)) as VersionControlServer;

                // Do what you need to do with it here
            }               
        }

        return value;
    }

    public override UITypeEditorEditStyle GetEditStyle(System.ComponentModel.ITypeDescriptorContext context)
    {
        return UITypeEditorEditStyle.Modal;
    }

最佳答案

您可以从 IBuildServer 获取 TfsTeamProjectProjection 对象:

http://msdn.microsoft.com/en-us/library/microsoft.teamfoundation.build.client.ibuildserver.teamprojectcollection.aspx

然后从这个对象中获取 Uri。

关于c# - TFS 自定义构建模板 - 获取不带 Uri 的团队项目集合,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10046216/

相关文章:

c# - C# 和 SQL Server 中 int 到 guid 的不同转换

visual-studio-2015 - 我在哪里可以找到 Visual Studio 2015 中的 Microsoft.TeamFoundation.Build.Client?

tfs - 我如何找到我的TFS项目的过程模板

unit-testing - TFS 尽管构建是绿色的,但并非所有测试都运行

c# - 当你有一个抽象类型的数组时,如何访问不在抽象类型上的派生类型成员

c# - Silverlight Storyboard中的收缩面板

c# - 编辑 msi 数据库表

c# - 语法解释 <%= %>

tfs - 如何使用 TFS Team Build 保持项目结构

asp.net - TFS项目结构让简单的事情变得困难