Migrate ResolveOverlappingItemGroupConflicts and ResolvePublicOutputConflicts to MT#54355
Conversation
There was a problem hiding this comment.
Pull request overview
This PR migrates ResolveOverlappingItemGroupConflicts to MSBuild multi-threaded execution by ensuring any on-disk file checks resolve relative paths via TaskEnvironment instead of the process current working directory (fixing the class of issues reported in dotnet/msbuild#13778).
Changes:
- Marked
ResolveOverlappingItemGroupConflictsas[MSBuildMultiThreadableTask], implementedIMultiThreadableTask, and passedTaskEnvironmentinto conflict item evaluation. - Updated
ConflictItemto use an absolute path (viaTaskEnvironment) only for file I/O while preserving original item specs/metadata for outputs and display. - Made the assembly-version cache thread-safe (
ConcurrentDictionary) and added unit tests covering relativeHintPathresolution and legacy behavior withoutTaskEnvironment.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| test/Microsoft.NET.Build.Tasks.Tests/GivenTasksUseAbsolutePaths.cs | Adds regression tests for ResolveOverlappingItemGroupConflicts relative path resolution via TaskEnvironment and legacy behavior without it. |
| src/Tasks/Common/FileUtilities.MetadataReader.cs | Switches the shared version cache to ConcurrentDictionary to support multi-threaded task execution safely. |
| src/Tasks/Common/ConflictResolution/ResolvePublishOutputConflicts.cs | Marks ResolveOverlappingItemGroupConflicts as multi-threadable and routes conflict item creation through TaskEnvironment. |
| src/Tasks/Common/ConflictResolution/ConflictItem.cs | Introduces SourcePathForFileAccess to resolve relative paths via TaskEnvironment for file operations while keeping original metadata intact. |
JanProvaznik
left a comment
There was a problem hiding this comment.
have you ran the transitive analyzer locally?
|
@JanProvaznik Addressed all four comments in the latest commit:
Also ran the ThreadSafeTaskAnalyzer locally against this branch — zero |
jankratochvilcz
left a comment
There was a problem hiding this comment.
Looks great, left a few smaller comments. One iteration and we're there I think :-)
jankratochvilcz
left a comment
There was a problem hiding this comment.
Please check out #54355 (comment). Other that that it's merge time 🚀
This reverts commit 9ce87da.
Fixes dotnet/msbuild#13778
Context
ResolveOverlappingItemGroupConflictsperforms file existence and version checks throughConflictItem, which previously resolved relative paths against the current working directory. That is unsafe for multithreaded MSBuild execution, where tasks can run on nodes with different working directories.Changes Made
ResolveOverlappingItemGroupConflictsas[MSBuildMultiThreadableTask]IMultiThreadableTaskand routed path resolution throughTaskEnvironmentConflictItemto absolutize paths only for file access while preserving original item specs and metadata in outputsConcurrentDictionaryHintPathresolution and compatibility when noTaskEnvironmentis providedTesting
ResolveOverlappingItemGroupConflictswith relative pathsConflictItembehavior is preserved when not usingTaskEnvironment