msbuild
msbuild copied to clipboard
[Bug]: MSBuild reads projects multiple times, resulting in different project contents at different points in the build
Issue Description
When a Project is built on a new Node for the first time its contents are read by that node. This can lead to inconsistent views of the contents of that project between Nodes, because each Node keeps a Node-local cache of project files contents. This can lead users to incorrectly believe that in scenarios where the same project file is read multiple times (like a multi-targeted .NET SDK-style project) the outer build can change project file contents and the inner build will always reflect those changes.
Steps to Reproduce
- Create a multi-targeted .NET SDK style project
- Make a Target in that project that writes content to the project, and condition the target on an outer-build-only Target.
- Build the project using
/m
- Investigate the binlog and see the changes between the outer and inner builds
Expected Behavior
The project files content should be read once over the course of the build and that initial content should be used as the basis for all evaluation and execution.
Actual Behavior
Each time a Node loads a project for the first time, the file content is read leading to inconsistent views of the project across evaluations and executions on different Nodes.
Analysis
Fixes here are varied - some kind of central reading/coordination layer would need to be in place, and all XML file reads would need to happen over IPC to that coordination layer.
Versions & Configurations
No response