ToolTask.EnvironmentOverride 属性

定义

注意

Use EnvironmentVariables property

获取路径替代值。Gets the Path override value.

protected:
 virtual property System::Collections::Generic::Dictionary<System::String ^, System::String ^> ^ EnvironmentOverride { System::Collections::Generic::Dictionary<System::String ^, System::String ^> ^ get(); };
protected:
 virtual property System::Collections::Specialized::StringDictionary ^ EnvironmentOverride { System::Collections::Specialized::StringDictionary ^ get(); };
[System.Obsolete("Use EnvironmentVariables property")]
protected virtual System.Collections.Generic.Dictionary<string,string> EnvironmentOverride { get; }
protected virtual System.Collections.Specialized.StringDictionary EnvironmentOverride { get; }
[System.Obsolete("Use EnvironmentVariables property")]
protected virtual System.Collections.Specialized.StringDictionary EnvironmentOverride { get; }
[<System.Obsolete("Use EnvironmentVariables property")>]
member this.EnvironmentOverride : System.Collections.Generic.Dictionary<string, string>
member this.EnvironmentOverride : System.Collections.Specialized.StringDictionary
[<System.Obsolete("Use EnvironmentVariables property")>]
member this.EnvironmentOverride : System.Collections.Specialized.StringDictionary
Protected Overridable ReadOnly Property EnvironmentOverride As Dictionary(Of String, String)
Protected Overridable ReadOnly Property EnvironmentOverride As StringDictionary

属性值

Dictionary<String,String>
StringDictionary

任务的环境的新值。The new value for the Environment for the task.

属性

示例

using System;  
using Microsoft.Build.Utilities;  
using System.Collections.Specialized;  

/// <summary>  
/// CustomToolTask overrides the EnvironmentOverride property of ToolTask to add a directory  
/// to the Path environment variable of the process being executed  
/// </summary>  
abstract class CustomToolTask : ToolTask  
{  
      protected override StringDictionary EnvironmentOverride  
      {  
            get  
            {  
                  string newPath = Environment.GetEnvironmentVariable("Path", EnvironmentVariableTarget.Process) + @";C:\MyDirectory";  
                  StringDictionary result = new StringDictionary();  
                  result.Add("Path", newPath);  
                  return result;  
            }  
      }  
}  

注解

ExecuteTool 方法将这些环境变量传递给执行该工具的进程的 StartInfo。The ExecuteTool method passes these environment variables to the StartInfo of the process in which the tool executes. 不包含在 EnvironmentOverride 字典中的任何环境变量都是从执行 ExecuteTool 方法的进程继承而来的。Any environment variables not included in the EnvironmentOverride dictionary are inherited from the process in which the ExecuteTool method executes.

适用于