Skip to content

Migrate ResolvePackageFileConflicts to IMultiThreadableTask - #53943

Merged
jankratochvilcz merged 9 commits into
dotnet:mainfrom
SimaTian:migrate-resolve-package-file-conflicts
Jun 11, 2026
Merged

jankratochvilcz merged 9 commits into
dotnet:mainfrom
SimaTian:migrate-resolve-package-file-conflicts

Conversation

@SimaTian

@SimaTian SimaTian commented Apr 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixed dotnet/msbuild#13777

Migrate ResolvePackageFileConflicts to IMultiThreadableTask

Migrates ResolvePackageFileConflicts (MSBuild task in Microsoft.NET.Build.Tasks) to support concurrent multi-threaded execution by implementing IMultiThreadableTask with a TaskEnvironment property.

Why

From OrchardCore build profiling (see gist):

Metric Value
Invocations 193
Cold-build time 1,188 ms
Incremental-build time 713 ms (60% of cold — biggest incremental tax of any NET.Sdk task)
Log messages 5,836 (never reduced on incremental)

This migration does not address the incremental-build regression or log-volume issue directly but enables the task to run safely under the upcoming multi-threaded MSBuild execution model.

What changed

  • Task now carries [MSBuildMultiThreadableTask] and implements IMultiThreadableTask with a TaskEnvironment property.
  • All Path.GetFullPath / File.* / Directory.* / env-var callsites in ResolvePackageFileConflicts.cs and its helpers (including the shared ConflictResolution/ path) routed through TaskEnvironment so they resolve against the task's project directory rather than process CWD.
  • Output properties preserve relativity via AbsolutePath.OriginalValue — no user-observable change in task outputs.

Tests

  • New GivenAResolvePackageFileConflictsMultiThreading.cs behavioural tests: decoy-CWD path resolution, multi-process vs multi-threaded parity, output relativity, concurrent execution with xUnit [Collection("CwdSensitive")] for safety.
  • Existing tests unchanged & passing.

Review status

Internally reviewed via 3-round playbook (merge-group-review → expert-review-msbuild-migration → opus-4.7 adversarial). All rounds PASS.

Depends on polyfills infrastructure (already in main via #52909).

Copilot AI review requested due to automatic review settings April 17, 2026 08:51

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.

Pull request overview

This PR migrates ResolvePackageFileConflicts (a shared conflict-resolution MSBuild task) to participate in MSBuild’s upcoming multi-threaded execution model by implementing IMultiThreadableTask and routing relative path resolution through TaskEnvironment (project-directory rooted), with accompanying behavioral tests to validate CWD-independence and concurrency behavior.

Changes:

  • Mark ResolvePackageFileConflicts as multi-threadable and add a TaskEnvironment property used to resolve relative inputs against the project directory.
  • Plumb a path-resolver into ConflictItem so file existence/version reads operate on resolved (project-rooted) absolute paths.
  • Add new unit tests validating project-dir-based path resolution, parity across differing CWDs, output relativity, and concurrent execution behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/Tasks/Microsoft.NET.Build.Tasks.UnitTests/GivenAResolvePackageFileConflictsMultiThreading.cs Adds behavioral tests for CWD independence, output relativity, and concurrent execution.
src/Tasks/Common/ConflictResolution/ResolvePackageFileConflicts.cs Implements IMultiThreadableTask, introduces TaskEnvironment, and uses it to resolve relative paths for manifests/TFDs and conflict items.
src/Tasks/Common/ConflictResolution/ConflictItem.cs Adds optional path resolver and uses it for file I/O (exists and version reads).

SimaTian and others added 2 commits May 13, 2026 12:15
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@AlesProkop
AlesProkop marked this pull request as ready for review May 25, 2026 11:20

@jankratochvilcz jankratochvilcz 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.

Looks good! Left a couple of minor comments :-)

@jankratochvilcz jankratochvilcz 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.

Left one bit, please check it out :-)

@jankratochvilcz jankratochvilcz 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.

Looks good, thank you!

@AR-May AR-May left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Have not yet finished with reviewing this PR. Publishing intermediate comments.

@AR-May AR-May left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Overall looks good! My only unresolved question concerns the behavioral change in #53943 (comment)

@jankratochvilcz
jankratochvilcz enabled auto-merge (squash) June 11, 2026 10:19
@jankratochvilcz

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s), but failed to run 1 pipeline(s).

@jankratochvilcz

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s), but failed to run 1 pipeline(s).

@jankratochvilcz

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s), but failed to run 1 pipeline(s).

@jankratochvilcz
jankratochvilcz merged commit 846d56c into dotnet:main Jun 11, 2026
25 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 11.0-preview6 milestone Jun 12, 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.

[Multithreaded] Migrate ResolvePackageFileConflicts in SDK

6 participants