ToolTask.EnvironmentOverride Property

Definition

Caution

Use EnvironmentVariables property

Gets the Path override value.

[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; }

Property Value

The new value for the Environment for the task.

Attributes

Examples

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;  
            }  
      }  
}  

Remarks

The ExecuteTool method passes these environment variables to the StartInfo of the process in which the tool executes. Any environment variables not included in the EnvironmentOverride dictionary are inherited from the process in which the ExecuteTool method executes.

Applies to