-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Issue Description
MSBuild's logging infrastructure used multiple constructor overloads that made it easy to accidentally omit important ID values, and that BuildResult objects weren't preserving evaluation context when sent between nodes in distributed builds.
Problem Statement
BuildEventContext Construction Issues
MSBuild's BuildEventContext class had multiple public constructors that made it easy to accidentally drop ID values when creating derived contexts. This was particularly problematic for:
- Evaluation ID loss - Critical for correlating build events with specific project evaluations
- Inconsistent context chains - Parent contexts losing data when creating child contexts
- Performance overhead - Multiple heap allocations when chaining context updates
- Error-prone API - Easy to pass wrong parameters or omit values entirely
Distributed Build Evaluation ID Loss
In MSBuild's distributed build architecture, worker nodes evaluate and build projects independently, but the central BuildManager wasn't receiving complete evaluation context. The issues were:
- Missing serialization -
BuildResultobjects weren't serializing evaluation IDs during node communication - Incomplete worker population - Worker nodes weren't setting evaluation IDs in results before sending to central node
- Central state inconsistency - BuildRequestConfiguration objects losing track of which evaluation generated each result
- Broken traceability - Central node unable to correlate results with specific project evaluations
Steps to Reproduce
Discovered while @jaredpar was trying to create automated tooling to track certain build events via these linkages.
Expected Behavior
Every BuildEventContext should be logically derived from a parent context, and contain all of the linkage data that's logically 'shared' with that parent context. Examples:
- node contexts are top-level
- submission contexts may be top-level, but may be derived from a node context
- evaluation contexts must be associated with a node and submission
- and so on
Actual Behavior
Several logging locations that create buildeventcontexts from whole cloth miss one or more logically-required parent scope data fields.
Analysis
See #12946 for a detailed treatment.
Versions & Configurations
No response