Skip to content

Fix MT project-cache file access compatibility - #14871

Open
JanProvaznik wants to merge 2 commits into
mainfrom
janprovaznik-fix-mt-project-cache-compatibility
Open

JanProvaznik wants to merge 2 commits into
mainfrom
janprovaznik-fix-mt-project-cache-compatibility

Conversation

@JanProvaznik

Copy link
Copy Markdown
Member

Fixes #14824
Fixes #14825
Fixes #14826

Summary

  • Preserve FileAccessData values across TaskHost deserialization without changing the existing payload format.
  • Propagate ReportFileAccesses to TaskHost with packet-version compatibility, gate collection and replay, and keep reported accesses isolated per task execution context.
  • Reject -mt together with -reportFileAccesses using actionable MSB1073; programmatic BuildManager callers receive the equivalent validation.
  • Document why Detours attribution requires process-isolated worker nodes.

Compatibility

Project-cache lookup/materialization remains compatible with MT. Only Detours-based cache population is rejected because concurrent projects in one process cannot be attributed correctly. CLR2, CLR4, and negotiated .NET TaskHost packet formats retain compatible behavior.

Validation

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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
@JanProvaznik JanProvaznik self-assigned this Sep 14, 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

3 participants