Migrate ToolTask and Al task to TaskEnvironment API#13423
Merged
OvesN merged 20 commits intoApr 7, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Migrates the AL built-in task to the TaskEnvironment API to support thread-safe execution in multithreaded builds, and introduces a reusable ToolTask helper for propagating TaskEnvironment working directory/environment to spawned tool processes.
Changes:
- Updated
ALto implementIMultiThreadableTask, useTaskEnvironmentfor env var/path resolution, and override process start info creation to flow the virtualized environment/working directory. - Refactored
ToolTaskprocess start info creation and addedGetProcessStartInfoMultiThreadedhelper to applyTaskEnvironmentsettings to child processes. - Added/updated unit tests validating
ALandToolTaskpropagation behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/Utilities/ToolTask.cs | Extracts base PSI creation and adds a multithreaded helper to apply TaskEnvironment env/working directory. |
| src/Utilities.UnitTests/ToolTask_Tests.cs | Adds coverage for GetProcessStartInfoMultiThreaded propagation and override precedence. |
| src/Tasks/Al.cs | Makes AL multithreadable and routes env/path/process creation through TaskEnvironment. |
| src/Tasks.UnitTests/Al_Tests.cs | Updates existing tests to set TaskEnvironment and adds new tests for tool path + working directory propagation. |
…https://github.com/OvesN/msbuild into dev/veronikao/migrate-Al-task-to-TaskEnvironment-API
AR-May
approved these changes
Mar 23, 2026
AR-May
left a comment
Member
There was a problem hiding this comment.
Looks good to me, provided that @rainersigwald approves the change of public API in ToolTask. Just one small refactoring idea from me.
JanProvaznik
approved these changes
Mar 24, 2026
JanProvaznik
left a comment
Member
There was a problem hiding this comment.
extra file slipped in, I deleted it
lgtm let's wait for confirming with Rainer this change to ToolTask is acceptable
AR-May
requested changes
Mar 25, 2026
AR-May
reviewed
Mar 25, 2026
The test relied on FileAttributes.ReadOnly to force File.Delete to throw, but this is not cross-platform - Unix read-only attributes don't prevent deletion.
rainersigwald
previously approved these changes
Mar 27, 2026
This was referenced Jun 14, 2026
chore(deps): Bump the nuget-dependencies group with 12 updates
JerrettDavis/JD.MSBuild.Containers#13
Merged
Merged
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #13410
Fixes #13447
Context
The ToolTask and AL (Assembly Linker) task were migrated to use
TaskEnvironment.Changes Made
ToolTask.csIMultiThreadableTask— all ToolTask children now inheritTaskEnvironmentwith a defaultMultiProcessTaskEnvironmentDriver.multi-process and multithreaded modes. Applies GetWorkingDirectory() override (absolutized via
TaskEnvironment.GetAbsolutePath()) and task-level EnvironmentVariables/EnvironmentOverride on top.
Environment.GetEnvironmentVariablewas replaced with theTaskEnvironmentAPI call.TaskEnvironment.GetAbsolutePath().Al.csEnvironment.GetEnvironmentVariablewas replaced with theTaskEnvironmentAPI call.TaskEnvironment.GetAbsolutePath().Testing
New unit tests in
Al_Tests.csandToolTask_Tests.cs