0

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

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

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

我需要我 sulotion

我的编辑器代码:

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
}

}

4

1 回答 1

0

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

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

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

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

于 2013-09-17T10:38:55.863 回答