Migrate ToolTask and Al task to TaskEnvironment API#13423
Migrate ToolTask and Al task to TaskEnvironment API#13423OvesN merged 20 commits intodotnet:mainfrom
Conversation
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
left a comment
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
left a comment
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
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.
I meant to "comment" not approve, sorry.
ApplyEnvironmentOverrides moved inside SetUpProcessStartInfo. Added override for DeleteTempFile using AbsolutePath. Made Driver private again, expose only enum value to decided if driver is multitheaded. Made GetProcessStartInfoMultithreadable private. add overload for DeleteTempFile with AbsolutePath argument
…e new API for falback task environment
… or null path before try catch in FindOnPath.
Fixes #13455 ### Context The SGen task was made thread-safe. ### Changes Made **SGen.cs** - Routed file existence checks and path resolution through TaskEnvironment.GetAbsolutePath(). ### Testing Unit tests in `SGen_Tests.cs` ### Notes - Should be merged after [Migrate ToolTask and Al task to TaskEnvironment API #13423](#13423) --------- Co-authored-by: Jan Provazník <janprovaznik@microsoft.com>
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