ToolTask.EnvironmentOverride Property
.NET Framework 4
Note: This API is now obsolete.
Gets a set of environment variable name-value pairs. Designed to be overridden in a custom task class (derived from ToolTask) to return a set of new or altered environment variables to create the execution context of the associated tool.
Assembly: Microsoft.Build.Utilities.v4.0 (in Microsoft.Build.Utilities.v4.0.dll)
[ObsoleteAttribute("Use EnvironmentVariables property")] protected virtual StringDictionary EnvironmentOverride { get; }
Property Value
Type: System.Collections.Specialized.StringDictionaryReturns a set of environment variables. Each dictionary key is the name of the environment variable to override and the dictionary value is the value to set for that environment variable. The default implementation of EnvironmentOverride returns null.
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;
}
}
}
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.