Skip to content

Reject file-access reporting with multithreaded builds - #14871

Merged
JanProvaznik merged 4 commits into
mainfrom
janprovaznik-fix-mt-project-cache-compatibility
Sep 21, 2026
Merged

JanProvaznik merged 4 commits into
mainfrom
janprovaznik-fix-mt-project-cache-compatibility

Conversation

@JanProvaznik

@JanProvaznik JanProvaznik commented Aug 28, 2026 •

Copy link
Copy Markdown
Member

Fixes #14825

Summary

  • Reject -mt together with -reportFileAccesses using actionable MSB1073, rather than failing later with an internal node-allocation error.
  • Apply equivalent early validation to programmatic BuildManager callers.
  • Document why Detours attribution requires process-isolated worker nodes, and explain how to disable MT when it was enabled through environment variables.

Compatibility and scope

Project-cache lookup/materialization remains compatible with MT. Only the unsupported combination of MT and Detours-based file-access reporting is rejected. Either mode remains available individually.

TaskHost supplemental file-access reporting repairs for #14824 and #14826 are deferred. This PR no longer changes TaskHost transport, collection, replay, or deserialization, and does not bump the packet protocol version. Ordinary native Detours tracking is separate from those supplemental reports.

Merged current main, preserving its TaskHost ownership, cancellation, and console-forwarding changes.

Validation

  • Affected engine and command-line test projects build successfully with zero warnings/errors.
  • Focused engine API regression: 1 passed on net472.
  • MT command-line regressions: 40 passed on net472 and 38 passed on net11.0.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 85b185e7-08c7-4a95-aa04-d674ec05a321
@JanProvaznik

Copy link
Copy Markdown
Member Author

/review

@JanProvaznik
JanProvaznik marked this pull request as ready for review September 8, 2026 15:35
Copilot AI lite review requested due to automatic review settings September 8, 2026 15:35

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.

🔵 Needs a closer look

It changes wire protocol/versioning and TaskHost/engine execution behavior in a broad, compatibility-sensitive area that warrants final human review.

Pull request overview

This PR improves compatibility and correctness of file-access reporting when tasks execute in out-of-proc TaskHosts, especially under experimental multi-threaded (-mt) builds, while preserving backward-compatible TaskHost packet behavior.

Changes:

  • Fixes FileAccessData round-tripping by avoiding struct boxing during TaskHost completion packet deserialization.
  • Propagates and gates ReportFileAccesses across TaskHost configuration + replay, and rejects -mt combined with -reportFileAccesses (CLI + BuildManager).
  • Updates protocol versioning, resources/localization, unit tests, and multithreading spec documentation accordingly.
File summaries
File Description
src/Shared/TaskHostTaskComplete.cs Fix struct translation to preserve FileAccessData through deserialization.
src/Shared/TaskHostConfiguration.cs Add versioned ReportFileAccesses flag to TaskHost configuration packet.
src/MSBuild/XMake.cs Reject incompatible -mt + -reportFileAccesses at command-line parsing.
src/MSBuild/TaskExecutionContext.cs Add per-task file-access collection gated by configuration.
src/MSBuild/OutOfProcTaskHostNode.cs Collect file accesses per task execution context and serialize per-task results.
src/MSBuild/Resources/Strings.resx Add MSB1073 message for incompatible switch combination.
src/MSBuild/Resources/xlf/Strings.zh-Hant.xlf Localized resource entry for MSB1073 (new string).
src/MSBuild/Resources/xlf/Strings.zh-Hans.xlf Localized resource entry for MSB1073 (new string).
src/MSBuild/Resources/xlf/Strings.tr.xlf Localized resource entry for MSB1073 (new string).
src/MSBuild/Resources/xlf/Strings.ru.xlf Localized resource entry for MSB1073 (new string).
src/MSBuild/Resources/xlf/Strings.pt-BR.xlf Localized resource entry for MSB1073 (new string).
src/MSBuild/Resources/xlf/Strings.pl.xlf Localized resource entry for MSB1073 (new string).
src/MSBuild/Resources/xlf/Strings.ko.xlf Localized resource entry for MSB1073 (new string).
src/MSBuild/Resources/xlf/Strings.ja.xlf Localized resource entry for MSB1073 (new string).
src/MSBuild/Resources/xlf/Strings.it.xlf Localized resource entry for MSB1073 (new string).
src/MSBuild/Resources/xlf/Strings.fr.xlf Localized resource entry for MSB1073 (new string).
src/MSBuild/Resources/xlf/Strings.es.xlf Localized resource entry for MSB1073 (new string).
src/MSBuild/Resources/xlf/Strings.de.xlf Localized resource entry for MSB1073 (new string).
src/MSBuild/Resources/xlf/Strings.cs.xlf Localized resource entry for MSB1073 (new string).
src/MSBuild.UnitTests/XMake_Tests.cs Add CLI and TaskHost behavior regression coverage (incompatibility + file access transport).
src/Framework/BackEnd/NodePacketTypeExtensions.cs Bump packet version and define min version for new TaskHostConfiguration field.
src/Build/Instance/TaskFactories/TaskHostTask.cs Propagate ReportFileAccesses into TaskHost config; gate replay on build parameters.
src/Build/BackEnd/BuildManager/BuildParameters.cs Document incompatibility between MultiThreaded and ReportFileAccesses.
src/Build/BackEnd/BuildManager/BuildManager.cs Reject incompatible combination for programmatic callers at BeginBuild.
src/Build/Resources/Strings.resx Add engine-level error string for incompatible configuration.
src/Build/Resources/xlf/Strings.zh-Hant.xlf Localized resource entry for engine-level incompatible configuration (new string).
src/Build/Resources/xlf/Strings.zh-Hans.xlf Localized resource entry for engine-level incompatible configuration (new string).
src/Build/Resources/xlf/Strings.tr.xlf Localized resource entry for engine-level incompatible configuration (new string).
src/Build/Resources/xlf/Strings.ru.xlf Localized resource entry for engine-level incompatible configuration (new string).
src/Build/Resources/xlf/Strings.pt-BR.xlf Localized resource entry for engine-level incompatible configuration (new string).
src/Build/Resources/xlf/Strings.pl.xlf Localized resource entry for engine-level incompatible configuration (new string).
src/Build/Resources/xlf/Strings.ko.xlf Localized resource entry for engine-level incompatible configuration (new string).
src/Build/Resources/xlf/Strings.ja.xlf Localized resource entry for engine-level incompatible configuration (new string).
src/Build/Resources/xlf/Strings.it.xlf Localized resource entry for engine-level incompatible configuration (new string).
src/Build/Resources/xlf/Strings.fr.xlf Localized resource entry for engine-level incompatible configuration (new string).
src/Build/Resources/xlf/Strings.es.xlf Localized resource entry for engine-level incompatible configuration (new string).
src/Build/Resources/xlf/Strings.de.xlf Localized resource entry for engine-level incompatible configuration (new string).
src/Build/Resources/xlf/Strings.cs.xlf Localized resource entry for engine-level incompatible configuration (new string).
src/Build.UnitTests/BackEnd/TaskHostTaskComplete_Tests.cs Add regression test ensuring FileAccessData round-trips correctly.
src/Build.UnitTests/BackEnd/TaskHostFactory_Tests.cs Add regression tests for TaskHost gating + replay logic.
src/Build.UnitTests/BackEnd/TaskHostConfiguration_Tests.cs Add regression tests for protocol-version-gated ReportFileAccesses.
src/Build.UnitTests/BackEnd/BuildManager_Tests.cs Add regression test for programmatic incompatibility rejection pre-build.
documentation/specs/multithreading/multithreaded-msbuild.md Document /reportfileaccesses incompatibility with current MT implementation.
Review details
  • Files reviewed: 43/43 changed files
  • Comments generated: 1
  • Review effort level: Lite

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

Comment thread src/MSBuild/TaskExecutionContext.cs Resolved
@JanProvaznik JanProvaznik self-assigned this Sep 14, 2026
Keep this PR focused on rejecting multithreaded builds with file-access reporting. Defer the TaskHost transport, collection, and replay repairs, leaving its protocol version and implementation identical to main.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 85b185e7-08c7-4a95-aa04-d674ec05a321
@JanProvaznik JanProvaznik changed the title Fix MT project-cache file access compatibility Reject file-access reporting with multithreaded builds Sep 16, 2026
@JanProvaznik
JanProvaznik requested a review from AR-May September 16, 2026 15:56

@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 to me. We probably should keep an open issue for fixing incompatibility of those two features to the backlog?

Comment thread src/MSBuild/Resources/Strings.resx Resolved
Move file-access reporting into a known-incompatibilities section. Clear deferred build messages in a finally block when BeginBuild throws, with regression coverage to prevent leaking messages into later builds.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 85b185e7-08c7-4a95-aa04-d674ec05a321
@JanProvaznik

Copy link
Copy Markdown
Member Author

@AR-May Addressed the documentation placement and deferred-message cleanup in a860ad1, with regression coverage for messages leaking after a failed BeginBuild. Kept the error text inline as discussed. Could you take another look?

@JanProvaznik
JanProvaznik enabled auto-merge (squash) September 17, 2026 14:24
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 MSBuild (-mt) is incompatible with -reportfileaccesses: MSB0001 'We failed to request a node to be created'

4 participants