カスタム プロセス パラメーター用のカスタム エディターを追加しますが、アセンブリを「カスタム アセンブリへのバージョン管理パス」に追加し、ビルド定義を編集するとエディターが表示されないのはなぜですか?
アセンブリを Visual Studio プローブ パスに追加すると、機能します
しかし、このビルドを使用するすべてのクリントにアセンブリをメニュー的にコピーしたくないので、ソース管理からアセンブリを使用したいのですが、機能しません
i need i 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
}
}