Skip to content

Expose public API for TaskEnvironment construction#13383

Open
AR-May wants to merge 4 commits intodotnet:mainfrom
AR-May:expose-default-task-environment
Open

Expose public API for TaskEnvironment construction#13383
AR-May wants to merge 4 commits intodotnet:mainfrom
AR-May:expose-default-task-environment

Conversation

@AR-May
Copy link
Member

@AR-May AR-May commented Mar 13, 2026

Context

With the discovery of the "direct instantiation of the task" use case, tasks must explicitly set a default task environment in order to work correctly. Task authors may encounter the same issue, without having benefit of having framework internals visible to them and thus without ability to create one without re-implementing the driver themselves. So, we need to provide a public API for TaskEnvironment construction to enable setting the default task environment. Would be helpful for sdk as well.

Changes Made

Adds two public API members to TaskEnvironment so that task authors using IMultiThreadableTask can obtain or create a TaskEnvironment without depending on internal types:

  • TaskEnvironment.Default: static singleton that delegates to the process-level environment (multi-process mode).
  • TaskEnvironment.CreateMultithreaded(projectDirectory, environmentVariables?): factory method that creates an isolated environment for multithreaded execution mode.

Testing

Unit tests

Note

Depends on #13380

Copilot AI review requested due to automatic review settings March 13, 2026 15:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to make Microsoft.Build.Framework.TaskEnvironment directly instantiable by task authors by adding a public parameterless constructor that selects a default environment driver.

Changes:

  • Add a public TaskEnvironment() constructor intended to default to the multi-process driver.

@AR-May AR-May changed the title Expose public constructor for TaskEnvironment. Expose public API for TaskEnvironment construction Mar 24, 2026
@AR-May
Copy link
Member Author

AR-May commented Mar 24, 2026

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants