Skip to content

Migrate CreateWixCommandPackageDropBase to multithreaded MSBuild - #17522

Merged
ViktorHofer merged 2 commits into
dotnet:mainfrom
ViktorHofer:mt-safe-subset-5
Sep 9, 2026
Merged

ViktorHofer merged 2 commits into
dotnet:mainfrom
ViktorHofer:mt-safe-subset-5

Conversation

@ViktorHofer

Copy link
Copy Markdown
Member

Follow-up to #17513, which migrated the rest of Microsoft.DotNet.Build.Tasks.Installers but left CreateLightCommandPackageDrop opted out.

That exclusion was structural rather than intrinsic. Nearly all of the task's execution lives in its abstract base, CreateWixCommandPackageDropBase, which passed raw paths to File/Directory APIs. The base was also invisible to the analyzer: the path rules are scoped to types carrying [MSBuildMultiThreadableTask] or implementing IMultiThreadableTask, and the base did neither, so only the derived class's own File.Copy was ever checked. The base lives in this same assembly and has exactly one derived class, so it can simply be migrated.

  • Hoist TaskEnvironment onto CreateWixCommandPackageDropBase and have it implement IMultiThreadableTask, which brings its members under analyzer coverage.
  • Resolve packageDropOutputFolder once at the entry of ProcessWixCommand and thread the AbsolutePath through the private helpers.
  • Resolve the AdditionalBasePaths probe in ProcessXPath. Paths read out of the wixobj XML keep their original form when reported, because oldPath is only reassigned once a candidate is found.
  • Keep the OutputFile [Output] property in the form the project supplied through OutputFolder; only the copy used for file I/O is resolved.
  • Mark CreateLightCommandPackageDrop with [MSBuildMultiThreadableTask] and drop its local TaskEnvironment, which the base now provides.

The produced wixpack is unchanged: the generated create.cmd embeds only file names, and zip entry names are relative to the source directory.

Validation

Builds with 0 warnings. Verified the base class is genuinely under analyzer coverage now, rather than just re-annotated, by temporarily reverting one call site in CreateWixCommandPackageDropBase and confirming it fails with MSBuildTask0003 — on main that same revert produces no diagnostic at all.

…Drop

Closes the last multithreading hole in this assembly. CreateLightCommandPackageDrop
was previously left un-attributed because nearly all of its execution lives in the
abstract base, which passed raw paths to File/Directory APIs. The base was also
invisible to the analyzer, since the path rules are scoped to types carrying
[MSBuildMultiThreadableTask] or implementing IMultiThreadableTask, and the base did
neither. Only the derived class's own File.Copy was checked.

- Hoist TaskEnvironment onto CreateWixCommandPackageDropBase and have it implement
  IMultiThreadableTask, which brings its members under analyzer coverage.
- Resolve packageDropOutputFolder once at the entry of ProcessWixCommand and thread
  the AbsolutePath through the private helpers.
- Resolve the AdditionalBasePaths probe in ProcessXPath. Paths read out of the
  wixobj XML keep their original form when reported, because oldPath is only
  reassigned once a candidate is found.
- Keep the OutputFile [Output] property in the form the project supplied through
  OutputFolder; only the copy used for file I/O is resolved.
- Mark CreateLightCommandPackageDrop with [MSBuildMultiThreadableTask] and drop its
  local TaskEnvironment, which the base now provides.

The generated create.cmd embeds only file names, and zip entry names are relative to
the source directory, so the produced wixpack is unchanged.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: be19d794-fe4f-43fe-9e6e-f6e6b13ec6e7
Copilot AI lite review requested due to automatic review settings September 9, 2026 12:27

Copilot AI left a comment

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.

Copilot review overview

🟢 Approval recommended

The path-resolution changes consistently follow existing repo patterns for multithreaded MSBuild tasks, and the remaining feedback is a non-blocking maintainability improvement.

Review tier: Lite
Findings: 1 Low severity

New issues introduced by this change (1)
Severity Finding
Low severity src/​Microsoft.DotNet.Build.Tasks.Installers/​src/​CreateWixCommandPackageDropBase.cs — ProcessToolSpecificCommandLineParameters still uses a string parameter, but the base now flows an…
What changed in this PR

Migrates CreateWixCommandPackageDropBase (and thus CreateLightCommandPackageDrop) to be safe under multithreaded MSBuild execution by ensuring all filesystem I/O uses TaskEnvironment-resolved paths and by opting the task into the multithreadable task host.

Changes:

  • Implement IMultiThreadableTask on CreateWixCommandPackageDropBase and add TaskEnvironment for project-relative path resolution.
  • Resolve key inputs/outputs (packageDropOutputFolder, OutputFolder/OutputFile, wix/loc inputs, and AdditionalBasePaths probes) to AbsolutePath before file/directory operations.
  • Mark CreateLightCommandPackageDrop with [MSBuildMultiThreadableTask] and remove its redundant local TaskEnvironment implementation.
File Description
src/​Microsoft.DotNet.Build.Tasks.Installers/​src/​CreateWixCommandPackageDropBase.cs Hoists TaskEnvironment and threads AbsolutePath through helpers so all file I/O is analyzer-covered and project-relative under multithreaded MSBuild.
src/​Microsoft.DotNet.Build.Tasks.Installers/​src/​CreateLightCommandPackageDrop.cs Opts the task into multithreaded execution and relies on the base for TaskEnvironment.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Preserves the type signal end-to-end instead of relying on an implicit
conversion at the override boundary.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: be19d794-fe4f-43fe-9e6e-f6e6b13ec6e7
Copilot AI review requested due to automatic review settings September 9, 2026 12:34

Copilot AI left a comment

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.

Copilot review overview

🟡 Changes recommended

It introduces a breaking change by modifying a protected abstract method signature on a public, packable task base type, which can break external derived-task consumers.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review tier: Lite
Findings: 1 High severity · 1 Low severity

New issues introduced by this change (2)
Severity Finding
High severity src/​Microsoft.DotNet.Build.Tasks.Installers/​src/​CreateWixCommandPackageDropBase.cs — Changing the protected abstract method signature from string to AbsolutePath is a breaking…
Low severity src/​Microsoft.DotNet.Build.Tasks.Installers/​src/​CreateLightCommandPackageDrop.cs — If the base restores the original ProcessToolSpecificCommandLineParameters(string, ...) for API…
Issues resolved since last review (1)
Severity Finding
Low severity src/​Microsoft.DotNet.Build.Tasks.Installers/​src/​CreateWixCommandPackageDropBase.cs — ProcessToolSpecificCommandLineParameters still uses a string parameter, but the base now flows an… View resolved comment

Copilot AI left a comment

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.

Copilot review overview

🟢 Approval recommended

The focused migration consistently resolves file-system paths without changing generated package semantics.

Review tier: Balanced
Findings: None

Issues resolved since last review (2)
Severity Finding
Low severity src/​Microsoft.DotNet.Build.Tasks.Installers/​src/​CreateLightCommandPackageDrop.cs — If the base restores the original ProcessToolSpecificCommandLineParameters(string, ...) for API… View resolved comment
High severity src/​Microsoft.DotNet.Build.Tasks.Installers/​src/​CreateWixCommandPackageDropBase.cs — Changing the protected abstract method signature from string to AbsolutePath is a breaking… View resolved comment

@ViktorHofer
ViktorHofer merged commit 8076506 into dotnet:main Sep 9, 2026
12 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 10, 2026
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.

3 participants