Skip to content

Migrate Al task to TaskEnvironment API#13423

Open
OvesN wants to merge 8 commits intodotnet:mainfrom
OvesN:dev/veronikao/migrate-Al-task-to-TaskEnvironment-API
Open

Migrate Al task to TaskEnvironment API#13423
OvesN wants to merge 8 commits intodotnet:mainfrom
OvesN:dev/veronikao/migrate-Al-task-to-TaskEnvironment-API

Conversation

@OvesN
Copy link
Contributor

@OvesN OvesN commented Mar 20, 2026

Fixes #13410

Context

The AL (Assembly Linker) task was made thread-safe.

Changes Made

Al.cs

  • Environment.GetEnvironmentVariable was replaced with the TaskEnvironment API call.
  • Routed file existence checks and path resolution through TaskEnvironment.GetAbsolutePath().
  • Overrode GetProcessStartInfo so we pass the working directory and environment from TaskEnvironment to the child spawned process.

ToolTask.cs

  • Added GetProcessStartInfoMultithreadable — a protected helper that passes the environment and working directory from TaskEnvironment to the child spawned process.

Testing

Al_Tests.cs

  • GenerateFullPathToTool_ReturnsAbsolutePathOrNull — validates the TaskEnvironment.GetAbsolutePath() integration.
  • GetProcessStartInfo_UsesTaskEnvironmentWorkingDirectory — verifies that the working directory from MultiThreadedTaskEnvironmentDriver is propagated to the child process.

ToolTask_Tests.cs

  • GetProcessStartInfoMultiThreaded_ShouldPropagateWorkingDirectory — verifies that environment variables and the working directory from MultiThreadedTaskEnvironmentDriver are propagated.
  • GetProcessStartInfoMultiThreaded_EnvironmentVariablesOverride — verifies that task-level EnvironmentVariables overrides take precedence over TaskEnvironment values.

Notes

  • The GetProcessStartInfoMultiThreaded helper in ToolTask can be reused by other ToolTask child tasks that will be migrated to the TaskEnvironment API.

Copilot AI review requested due to automatic review settings March 20, 2026 13:25
@OvesN OvesN requested review from AR-May and JanProvaznik March 20, 2026 13:26
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

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 AL to implement IMultiThreadableTask, use TaskEnvironment for env var/path resolution, and override process start info creation to flow the virtualized environment/working directory.
  • Refactored ToolTask process start info creation and added GetProcessStartInfoMultiThreaded helper to apply TaskEnvironment settings to child processes.
  • Added/updated unit tests validating AL and ToolTask propagation 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.

return startInfo;
}

protected ProcessStartInfo GetProcessStartInfoMultiThreaded(
Copy link
Member

Choose a reason for hiding this comment

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

Reviewer WARNING: API change

Copy link
Member

Choose a reason for hiding this comment

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

Needs discussion if this should be handled by this new method.
@rainersigwald

{
foreach (string responseFile in ResponseFiles)
{
commandLine.AppendSwitchIfNotNull("@", responseFile);
Copy link
Member

Choose a reason for hiding this comment

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

sanity check: this is not absolutized because the process starts with correct CWD, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, because GetProcessStartInfoMultiThreaded sets the spawned al.exe process's working directory to the project directory via TaskEnvironment. So al.exe itself resolves responseFile relative to the correct CWD.

Copy link
Member

@AR-May AR-May left a comment

Choose a reason for hiding this comment

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

Looks good to me, provided that @rainersigwald approves the change of public API in ToolTask. Just one small refactoring idea from me.

Copy link
Member

@JanProvaznik JanProvaznik left a comment

Choose a reason for hiding this comment

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

extra file slipped in, I deleted it
lgtm let's wait for confirming with Rainer this change to ToolTask is acceptable

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.

Migrate Al task to TaskEnvironment API

4 participants