【问题标题】:tfs build 2010 add custom editortfs build 2010 添加自定义编辑器
【发布时间】:2013-09-17 18:38:55
【问题描述】:

我为我们的自定义流程参数添加了一个自定义编辑器,但是将程序集添加到“自定义程序集的版本控制路径”中,当我编辑构建定义时,编辑器不显示,为什么?

当我将程序集添加到 Visual Studio 探测路径中时,它可以工作

但我不想将程序集菜单复制到使用此构建的所有 clints,所以我想使用源代码管理中的程序集但它不起作用

我需要我的解决方案

我的编辑器代码:

using System;
using System.ComponentModel;
using System.Drawing.Design;
using System.IO;
using System.Management;
using System.Windows.Forms;


namespace SVBuild
{

public class FolderBrowserEditor : UITypeEditor
{
    public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
    {
        if (context != null)
            return UITypeEditorEditStyle.Modal;

        return UITypeEditorEditStyle.None;
    }

    public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
    {
        FolderBrowserDialog fd;
        string path = "";
        string realPath = "";

        if (context == null || provider == null || context.Instance == null)
            return base.EditValue(provider, value);
        fd = new FolderBrowserDialog();
        fd.ShowNewFolderButton = true;
        fd.Description = "Select Folder";
        fd.RootFolder = Environment.SpecialFolder.MyComputer;
        if (fd.ShowDialog() == DialogResult.OK)
        {
            path = fd.SelectedPath;
            realPath = ResolveToUNC(path);
        }
        return realPath;
    }
    #region ResolveToUNC
    /// <summary>Resolves the given path to a full UNC path, or full local drive path.</summary>
    /// <param name="pPath"></param>
    /// <returns></returns>
    private string ResolveToUNC(string pPath)
    {
        if (pPath.StartsWith(@"\\")) { return pPath; }

        string root = ResolveToRootUNC(pPath);

        if (pPath.StartsWith(root))
        {
            return pPath; // Local drive, no resolving occurred
        }
        else
        {
            return pPath.Replace(GetDriveLetter(pPath), root);
        }
    }
    /// <summary>Resolves the given path to a root UNC path, or root local drive path.</summary>
    /// <param name="pPath"></param>
    /// <returns>\\server\share OR C:\</returns>
    private string ResolveToRootUNC(string pPath)
    {
        ManagementObject mo = new ManagementObject();

        if (pPath.StartsWith(@"\\")) { return Directory.GetDirectoryRoot(pPath); }

        // Get just the drive letter for WMI call
        string driveletter = GetDriveLetter(pPath);

        mo.Path = new ManagementPath(string.Format("Win32_LogicalDisk='{0}'", driveletter));

        // Get the data we need
        uint DriveType = Convert.ToUInt32(mo["DriveType"]);
        string NetworkRoot = Convert.ToString(mo["ProviderName"]);
        mo = null;

        // Return the root UNC path if network drive, otherwise return the root path to the local drive
        if (DriveType == 4)
        {
            return NetworkRoot;
        }
        else
        {
            return driveletter + Path.DirectorySeparatorChar;
        }
    }

    /// <summary>Checks if the given path is on a network drive.</summary>
    /// <param name="pPath"></param>
    /// <returns></returns>
    private bool isNetworkDrive(string pPath)
    {
        ManagementObject mo = new ManagementObject();

        if (pPath.StartsWith(@"\\")) { return true; }

        // Get just the drive letter for WMI call
        string driveletter = GetDriveLetter(pPath);

        mo.Path = new ManagementPath(string.Format("Win32_LogicalDisk='{0}'", driveletter));

        // Get the data we need
        uint DriveType = Convert.ToUInt32(mo["DriveType"]);
        mo = null;

        return DriveType == 4;
    }

    /// <summary>Given a path will extract just the drive letter with volume separator.</summary>
    /// <param name="pPath"></param>
    /// <returns>C:</returns>
    private string GetDriveLetter(string pPath)
    {
        if (pPath.StartsWith(@"\\")) { throw new ArgumentException("A UNC path was passed to GetDriveLetter"); }
        return Directory.GetDirectoryRoot(pPath).Replace(Path.DirectorySeparatorChar.ToString(), "");
    }
    #endregion
}

}

【问题讨论】:

    标签: tfsbuild


    【解决方案1】:

    有几件事可能会导致问题。

    1. 检查自定义程序集的映射
    2. 一旦将你的东西签入到 tfs 中,你必须重新启动 VS 才能工作,一旦你第一次打开进程选项卡,自定义程序集内容就会下载到 temp 文件夹
    3. GAC 或 VS 私有程序集中的任何程序集通常都会胜过下载的程序集。
    4. 确保您的构建参数元数据具有正确的命名空间等。
    5. 如果编辑器在引用的程序集中,您必须至少包含一个活动才能让工作流正确加载此程序集(不确定这是否会影响 VS 中的流程编辑器,但会导致构建问题)。

    您可以使用 VS 的另一个实例来调试有问题的实例,模块部分将告诉您加载了哪些内容以及从哪里加载,一旦您可以开始拼凑原因。

    如果这不能解决问题,请使用更多详细信息更新您的问题。

    【讨论】:

    • 我对自定义程序集进行了所有这些操作并重新启动 VS 我在 GAC 或私有程序集中没有程序集,构建参数元数据正常,并且此程序集的活动和此 donwt 显示.就在我将程序集复制到它显示的私有程序集时,但我希望它显示给所有客户端
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-11
    • 2010-11-03
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多