Skip to content

Migration of GenerateLauncher to Multithreaded Execution#13699

Open
AlesProkop wants to merge 3 commits into
dotnet:mainfrom
AlesProkop:migrate-generatelauncher-to-mt
Open

Migration of GenerateLauncher to Multithreaded Execution#13699
AlesProkop wants to merge 3 commits into
dotnet:mainfrom
AlesProkop:migrate-generatelauncher-to-mt

Conversation

@AlesProkop
Copy link
Copy Markdown
Member

@AlesProkop AlesProkop commented May 6, 2026

Fixes #13628

Context

GenerateLauncher delegates to LauncherBuilder for file copy/patching. Both LauncherPath and OutputPath were resolved relative to the process working directory, which is unsafe under multithreaded execution.

Changes Made

  • GenerateLauncher.cs: Added [MSBuildMultiThreadableTask] + IMultiThreadableTask. Absolutized LauncherPath/OutputPath via TaskEnvironment.GetAbsolutePath(), preserving originals for messages and outputs.
  • LauncherBuilder.cs: Added internal overloads accepting separate "for messages" paths to keep error messages user-friendly. Public API unchanged.

Testing

  • Build clean, no new warnings.
  • Sin 1 verified: no absolutized paths leak into [Output].
  • Sin 2 verified: error messages use original paths.

@AlesProkop AlesProkop changed the title migrate generatelauncher [ DRAFT][DNR] Migration of GenerateLauncher to Multithreaded Execution May 6, 2026
@AlesProkop AlesProkop marked this pull request as ready for review May 6, 2026 13:02
Copilot AI review requested due to automatic review settings May 6, 2026 13:02
Copy link
Copy Markdown
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 migrates the GenerateLauncher built-in task to MSBuild’s multithreaded execution model by removing reliance on process working directory for path resolution, while preserving user-facing and [Output] path strings.

Changes:

  • Mark GenerateLauncher as [MSBuildMultiThreadableTask] and implement IMultiThreadableTask with a TaskEnvironment property.
  • Absolutize LauncherPath and OutputPath via TaskEnvironment.GetAbsolutePath() for file operations, while keeping the original strings for outputs and error messages.
  • Extend LauncherBuilder with internal overloads to accept “for messages” paths separately from the paths used for I/O.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/Tasks/GenerateLauncher.cs Adds multithreaded task declaration + uses TaskEnvironment to absolutize paths for I/O while preserving original paths for outputs/messages.
src/Tasks/ManifestUtil/LauncherBuilder.cs Adds internal constructor/build overloads to keep messages using original path strings while performing I/O with absolutized paths.

Comment thread src/Tasks/GenerateLauncher.cs Outdated
@rainersigwald
Copy link
Copy Markdown
Member

looks like I messed up #13641 and @sujitnayak did not automatically get added as a reviewer. Fixing that . . .

@rainersigwald rainersigwald requested a review from a team May 11, 2026 17:23
Comment thread src/Tasks/GenerateLauncher.cs Outdated
}

var launcherBuilder = new LauncherBuilder(LauncherPath);
string launcherPath = string.IsNullOrEmpty(LauncherPath) ? LauncherPath : TaskEnvironment.GetAbsolutePath(LauncherPath);
Copy link
Copy Markdown
Contributor

@sujitnayak sujitnayak May 11, 2026

Choose a reason for hiding this comment

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

LauncherPath is always null initially since it is not passed in as a task argument. It gets converted to absolute path above. I don't think this check is necessary here since Launcher path will be non-null and absolute when we get here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

You are right, we can just use LauncherPath.


var launcherBuilder = new LauncherBuilder(LauncherPath);
string launcherPath = string.IsNullOrEmpty(LauncherPath) ? LauncherPath : TaskEnvironment.GetAbsolutePath(LauncherPath);
string outputPath = string.IsNullOrEmpty(OutputPath) ? OutputPath : TaskEnvironment.GetAbsolutePath(OutputPath);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If an absolute path gets passed in this task parameter, will this call still do the right thing?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, TaskEnvironment.GetAbsolutePath() is no-op for already absolute paths.

}

OutputEntryPoint = new TaskItem(Path.Combine(Path.GetDirectoryName(EntryPoint.ItemSpec), results.KeyFile));
string outputEntryPoint = Path.Combine(Path.GetDirectoryName(EntryPoint.ItemSpec), results.KeyFile);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we convert to absolute path at point of use instead of having to pass the output path twice?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think that this pair is the best fit here. Per migration guidelines, the output/logging cannot change Collapsing into one would either inflate error messages or require pushing TaskEnviromentinto LauncherBuilder which feels redundant in this PR. Happy to do the refactor if you would prefer.

@AlesProkop AlesProkop requested a review from sujitnayak May 12, 2026 06:48
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 GenerateLauncher to multithreaded execution

4 participants