TFS自定义生成模板-获取不包含Uri的团队项目集合

本文关键字:Uri 包含 团队 集合 项目 获取 自定义 TFS | 更新日期: 2023-09-27 18:30:10

是否存在从IBuildDefinition或其他相关"服务"获取集合URI的方法。

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

有没有一种方法可以在不使用硬编码的情况下对此进行查询?在我看来,构建过程本身(定义、控制器、代理等)知道他们在处理哪个集合,但我怎么才能知道呢?

更新:这是从UITypeEditor继承时的示例代码。然后您只需访问VersionControlService:的TeamProjectCollection属性

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

TFS自定义生成模板-获取不包含Uri的团队项目集合

您可以从IBuildServer:获取TfsTeamProjectProjection对象

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

然后从该对象获取Uri。

UITypeEditor.EditValue的重写内部获取TeamProjectCollection的相关代码行是

VersionControlServer vcs = provider.GetService(typeof(VersionControlServer)) as VersionControlServer;

然后它在属性中

vcs.TeamProjectCollection