Repository navigation
Migrate Microsoft.DotNet.Build.Tasks.Installers to multithreaded MSBuild - #17513
Merged
Merged
Conversation
Opts the deb/rpm/macOS/wixpack tasks into [MSBuildMultiThreadableTask] and resolves every path that reaches file I/O through TaskEnvironment, so they no longer depend on the process current directory. - CreateChangelogFile, CreateControlFile, CreateDebPackage, CreateMD5SumsFile, CreateRpmPackage, GenerateMacOSDistributionFile, StabilizeWixFileId: resolve output/input paths at the point of use. - CreateWixBuildWixpack: thread the resolved working directory through the helper chain instead of reading the raw property, and suppress MSBuildTask0002 where the temp root is only a parent for a freshly generated unique name. - ExecWithRetries: forward TaskEnvironment to the nested Exec instance, which MSBuild does not inject into task-created children. - CreateLightCommandPackageDrop: not opted in; most of its work lives in CreateWixCommandPackageDropBase, which still passes raw paths. It implements IMultiThreadableTask only to receive TaskEnvironment. Tracked by dotnet#17378. Co-authored-by: Copilot <[email protected]> Copilot-Session: be19d794-fe4f-43fe-9e6e-f6e6b13ec6e7
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The tasks correctly opt into multithreaded routing and consistently resolve file I/O paths via TaskEnvironment without introducing new unchecked null-path or raw-path I/O in the modified regions.
Review tier: Lite
Findings: None
What changed in this PR
This PR migrates several Microsoft.DotNet.Build.Tasks.Installers MSBuild tasks to be safe for MSBuild’s in-proc multi-threaded execution (-mt) by opting into [MSBuildMultiThreadableTask] and resolving all file I/O paths via TaskEnvironment so relative paths bind to the project directory rather than the shared node process directory.
Changes:
- Annotated the targeted installer tasks with
[MSBuildMultiThreadableTask]and implementedIMultiThreadableTaskwith an injectedTaskEnvironmentproperty. - Updated file/directory/process call sites to use
TaskEnvironment.GetAbsolutePath(...)(and threadedAbsolutePaththrough helper chains where needed, notably inCreateWixBuildWixpack). - Ensured nested
Execusage inExecWithRetriesinherits the outer task’sTaskEnvironmentfor correctWorkingDirectoryresolution.
| File | Description |
|---|---|
| src/Microsoft.DotNet.Build.Tasks.Installers/src/StabilizeWixFileId.cs | Opts into multithreaded MSBuild and resolves input/output XML paths via TaskEnvironment. |
| src/Microsoft.DotNet.Build.Tasks.Installers/src/GenerateMacOSDistributionFile.cs | Opts into multithreaded MSBuild and resolves template/output paths via TaskEnvironment. |
| src/Microsoft.DotNet.Build.Tasks.Installers/src/ExecWithRetries.cs | Opts into multithreaded MSBuild and forwards TaskEnvironment into the nested Exec instance. |
| src/Microsoft.DotNet.Build.Tasks.Installers/src/CreateWixBuildWixpack.cs | Opts into multithreaded MSBuild; resolves/threads working directory and related file I/O paths using TaskEnvironment/AbsolutePath. |
| src/Microsoft.DotNet.Build.Tasks.Installers/src/CreateRpmPackage.cs | Opts into multithreaded MSBuild and resolves script/payload/output paths via TaskEnvironment. |
| src/Microsoft.DotNet.Build.Tasks.Installers/src/CreateMD5SumsFile.cs | Opts into multithreaded MSBuild and resolves input/output paths via TaskEnvironment. |
| src/Microsoft.DotNet.Build.Tasks.Installers/src/CreateLightCommandPackageDrop.cs | Explicitly does not opt into routing; keeps IMultiThreadableTask only for TaskEnvironment injection and resolves select paths for local I/O. |
| src/Microsoft.DotNet.Build.Tasks.Installers/src/CreateDebPackage.cs | Opts into multithreaded MSBuild and resolves control/data/output paths via TaskEnvironment. |
| src/Microsoft.DotNet.Build.Tasks.Installers/src/CreateControlFile.cs | Opts into multithreaded MSBuild and resolves output path via TaskEnvironment. |
| src/Microsoft.DotNet.Build.Tasks.Installers/src/CreateChangelogFile.cs | Opts into multithreaded MSBuild and resolves output path via TaskEnvironment. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
ViktorHofer
enabled auto-merge (squash)
September 9, 2026 12:12
akoeplinger
approved these changes
Sep 9, 2026
This was referenced Sep 9, 2026
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.
Fourth safe subset of #17381. Opts the installer tasks into multithreaded MSBuild so they resolve paths against the project directory instead of the process current directory.
CreateChangelogFile,CreateControlFile,CreateDebPackage,CreateMD5SumsFile,CreateRpmPackage,GenerateMacOSDistributionFile,StabilizeWixFileId: resolve paths at the point of use. Log messages keep the original user-supplied path.CreateWixBuildWixpack: the resolved working directory is threaded through the helper chain rather than each helper re-reading the raw property.MSBuildTask0002is suppressed in the two places where the temp root is only the parent of a freshly generated unique name, so it is never shared between concurrent tasks.ExecWithRetries: forwardsTaskEnvironmentto the nestedExec. MSBuild only injects it into tasks it instantiates itself, so without this a relativeWorkingDirectorywould resolve against the shared node's current directory.CreateLightCommandPackageDrop: not opted in. Most of its execution lives inCreateWixCommandPackageDropBase, which still passes raw paths toFile/DirectoryAPIs. It implementsIMultiThreadableTaskwithout the attribute so it still receivesTaskEnvironmentfor the path resolution it does do — routing keys off the attribute alone, so the interface cannot opt it in by accident. Tracked by Annotate Arcade MSBuild tasks with [MSBuildMultiThreadableTask] to avoid TaskHost marshalling in -mt builds #17378.Validation
Microsoft.DotNet.Build.Tasks.Installersbuilds with 0 warnings. TheMicrosoft.Build.TaskAuthoring.Analyzerrules are errors for these tasks once they opt in, so every path flowing into file I/O is checked by the compiler. Verified the analyzer is actually active for this project by temporarily reverting one call site and confirming it fails withMSBuildTask0003.