Repository navigation
Make in-process ResolveAssemblyReference cancellable - #14959
rainersigwald merged 6 commits into
Conversation
Co-authored-by: Copilot App <[email protected]>
Keep cached dependency arrays and nested remapping sets unchanged. Add cancellation recovery regressions and meaningful cache-write controls. Co-authored-by: Copilot App <[email protected]>
|
@YuliiaKovalova inspired by our conversation |
|
supersedes #14235 |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Unresolved cancellation coverage gaps and a critical assembly-identity remapping issue must be addressed.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (4)
What changed in this PR
Adds cooperative cancellation to in-process ResolveAssemblyReference while isolating remapping state and preserving normal resolution behavior.
Changes:
- Propagates cancellation through resolution, traversal, conflicts, logging, and output.
- Prevents shared metadata-cache contamination during remapping.
- Adds cancellation/recovery tests and documentation.
| File | Description |
|---|---|
src/Tasks/AssemblyDependency/Resolver.cs |
Adds cancellation checks during resolution. |
src/Tasks/AssemblyDependency/ResolveAssemblyReference.cs |
Implements cancellation orchestration and handling. |
src/Tasks/AssemblyDependency/ReferenceTable.cs |
Propagates cancellation and isolates remapping state. |
src/Tasks/AssemblyDependency/AssemblyResolution.cs |
Passes cancellation through resolver creation. |
src/Tasks.UnitTests/AssemblyDependency/CancellationTests.cs |
Adds cancellation, recovery, and cache-isolation tests. |
documentation/wiki/ResolveAssemblyReference.md |
Documents cancellation behavior. |
|
/review |
|
❌ Expert Code Review (command) failed. Please review the logs for details. Warning Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding. What happenedThe threat detection engine failed to produce results. Review the workflow run logs for details. Warning Firewall blocked 3 domainsThe following domains were blocked by the firewall during workflow execution:
[!TIP] tools:
github:
mode: gh-proxySee GitHub Tools for more information on To allow these domains, add them to the network:
allowed:
- defaults
- "api.github.com"
- "github.com"
- "raw.githubusercontent.com"See Network Configuration for more information.
|
Reject pre-canceled remote dispatch, preserve completed state-file bookkeeping, avoid repeated remapping-set copies, and observe cancellation in remaining reference/output scans. Keep focused cancellation, cache recovery, and remapping isolation regressions. Co-authored-by: Copilot App <[email protected]>
Co-authored-by: Copilot App <[email protected]>
|
/backport to vs18.12 |
|
/backport to vs18.11 |
|
Started backporting to |
|
Started backporting to |
Fixes #12268 ### Context Canceling a build currently waits for ResolveAssemblyReference to finish its work. This is particularly noticeable with large reference sets and dependency graphs. Add cooperative cancellation for in-process RAR without changing normal resolution behavior. ### Changes Made - Implement `ICancelableTask` and propagate a cancellation token through reference resolution, dependency traversal, conflict handling, and output/logging loops. Handle this task's cancellation by returning `false` without introducing cancellation diagnostics. - Keep cache serialization uninterrupted once it starts, and balance the affected tracing events when execution unwinds. - Fix a pre-existing cache-isolation problem found while reviewing cancellation safety: dependency remapping modified arrays and nested remapping sets owned by the process-wide metadata cache. Remapping now uses task-local results so later tasks do not inherit another invocation's remappings. - Add deterministic cancellation and recovery tests, including shared folder-cache reuse, cold cache initialization, complete output metadata comparisons, and positive cache-write controls. Document cancellation semantics. ### Testing - Full repository build and bootstrap sample build succeeded. - Scoped RAR suites passed: 52 tests on `net11.0` and 433 on `net472`, including 18 cancellation cases on each runtime. Four cache-isolation regressions failed before the isolation fix and passed afterward. - Local end-to-end `BuildManager` stress probe: 20,000 references across 64 search paths. Eight cancellation runs, triggered after RAR entered closure computation, returned from `EndBuild()` in 57-73 ms. The non-cancellable SDK RAR baseline on the same engine took 33 seconds after cancellation. - Local same-process recovery probe: 512 generated signed primary assemblies, transitive dependencies, a real version conflict, and related/satellite/serializer outputs. Cold and warm cancellation, subsequent recovery, and timestamp invalidation preserved the expected output paths and metadata. Cancellation preserved the existing state file; timestamp invalidation updated it. CWD, PATH, and cultures remained unchanged. The end-to-end probes are local validation artifacts, not committed integration tests. ### Notes - In-process only; out-of-process RAR behavior and communication are unchanged. - Cancellation is cooperative, not a guarantee of bounded latency during synchronous I/O or cache initialization. A cache write already in progress may finish before the task returns `false`. - No new warnings/errors or ChangeWave. Uncancelled resolution semantics are preserved apart from preventing shared-cache contamination. --------- Co-authored-by: Copilot App <[email protected]>
# NET 11 Ask Mode ## Description RAR is a long running MSBuild task. When you cancel a build, it needs to finish running before MSBuild exits (seconds-minutes in large builds). This is perceived by customers as nonresponsivity/hang, especially in VS (which motivates this backport primarily since it's a top hang trace https://devdiv.visualstudio.com/DevDiv/_workitems/edit/3074347), The experience in non-VS CLI is also bad, that after cancelation from customer point of view nothing happens until RAR finishes. This change adds a cancelation token that can be signaled in many places of the RAR task, making the shutdown fast when requested. ## Regression? (was it working in a previous release or preview?) No ## Risk (see [taxonomy](https://dev.azure.com/devdiv/DevDiv/_wiki/wikis/DevDiv.wiki/545/NET-Servicing#risk-taxonomy)) Low Backport of #14959 to vs18.12 --------- Co-authored-by: Jan Provazník <[email protected]> Co-authored-by: Copilot App <[email protected]> Copilot-Session: b298eb1e-ffbe-414b-a2ad-f4255a11c4a2


Fixes #12268
Context
Canceling a build currently waits for ResolveAssemblyReference to finish its work. This is particularly noticeable with large reference sets and dependency graphs. Add cooperative cancellation for in-process RAR without changing normal resolution behavior.
Changes Made
ICancelableTaskand propagate a cancellation token through reference resolution, dependency traversal, conflict handling, and output/logging loops. Handle this task's cancellation by returningfalsewithout introducing cancellation diagnostics.Testing
net11.0and 433 onnet472, including 18 cancellation cases on each runtime. Four cache-isolation regressions failed before the isolation fix and passed afterward.BuildManagerstress probe: 20,000 references across 64 search paths. Eight cancellation runs, triggered after RAR entered closure computation, returned fromEndBuild()in 57-73 ms. The non-cancellable SDK RAR baseline on the same engine took 33 seconds after cancellation.The end-to-end probes are local validation artifacts, not committed integration tests.
Notes
false.