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