Skip to content

Revert "Fix RecursiveDir metadata loss in multithreaded builds"#13245

Merged
JanProvaznik merged 1 commit intomainfrom
revert-13142-fix-recursivedir-taskhost
Feb 12, 2026
Merged

Revert "Fix RecursiveDir metadata loss in multithreaded builds"#13245
JanProvaznik merged 1 commit intomainfrom
revert-13142-fix-recursivedir-taskhost

Conversation

@JanProvaznik
Copy link
Copy Markdown
Member

Reverts #13142

Breaks VMR and possibly other consumers of msbuild.

#3121 it fixes has been so longstanding, that customers have implemented workarounds which would break by fixing it. We should instead document it as a known limitation.

Should be partially reimplemented to address only #13140

@JanProvaznik JanProvaznik enabled auto-merge (squash) February 12, 2026 15:10
@JanProvaznik JanProvaznik merged commit b595efa into main Feb 12, 2026
16 checks passed
@JanProvaznik JanProvaznik deleted the revert-13142-fix-recursivedir-taskhost branch February 12, 2026 16:24
JanProvaznik added a commit to JanProvaznik/msbuild that referenced this pull request Feb 25, 2026
JanProvaznik added a commit to JanProvaznik/msbuild that referenced this pull request Mar 3, 2026
When using MSBuild's -mt mode (/maxcpucount), tasks without
[MSBuildMultiThreadableTask] are routed to out-of-process TaskHost
sidecars. Items passed to these tasks are serialized via
TaskParameterTaskItem, which calls CloneCustomMetadataEscaped() —
copying only custom metadata. RecursiveDir is a built-in metadata
that is non-derivable (requires _includeBeforeWildcardExpansionEscaped),
so it's lost during this serialization, returning empty string on
the TaskHost side.

This causes dotnet pack /mt to flatten directory structures in NuGet
packages (e.g., build/wix/bundle/bundle.wxs becomes build/bundle.wxs).

Fix: Explicitly copy RecursiveDir to custom metadata in the
TaskParameterTaskItem constructor before serialization, so it
survives the cross-process boundary.

Unlike the previous attempt (PR dotnet#13142, reverted in PR dotnet#13245),
this fix ONLY touches the TaskHost serialization boundary
(TaskParameterTaskItem). It does NOT change GatherTaskItemOutputs
or ProjectItemInstance, which was what caused the NuGet/sfxproj
double-append regression. Items that lose RecursiveDir at the
MSBuild task callback boundary (e.g., sfxproj targets returning
items via TargetOutputs) are unaffected — they already have
RecursiveDir=empty before reaching TaskParameterTaskItem.

Fixes dotnet#13140
Related: dotnet#3121

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

2 participants