TaskEnvironment.CreateWithProjectDirectoryAndEnvironment Method

Definition

Creates a new TaskEnvironment with isolated working directory and environment variables.

public static Microsoft.Build.Framework.TaskEnvironment CreateWithProjectDirectoryAndEnvironment(string projectDirectory, System.Collections.Generic.IDictionary<string,string>? environmentVariables = default);
static member CreateWithProjectDirectoryAndEnvironment : string * System.Collections.Generic.IDictionary<string, string> -> Microsoft.Build.Framework.TaskEnvironment
Public Shared Function CreateWithProjectDirectoryAndEnvironment (projectDirectory As String, Optional environmentVariables As IDictionary(Of String, String) = Nothing) As TaskEnvironment

Parameters

projectDirectory
String

The initial working directory for the task.

environmentVariables
IDictionary<String,String>

A dictionary of environment variables to use, or null to use the current process environment variables.

Returns

A new TaskEnvironment with isolated environment state.

Exceptions

projectDirectory is null.

projectDirectory is empty.

Remarks

This method is primarily intended for testing scenarios. In normal MSBuild operation, the correct task environment is provided by the MSBuild engine. The created TaskEnvironment provides isolated environment state similar to what tasks receive in multithreaded execution mode, enabling testing of task isolation behavior.

Applies to