Repository navigation
Fix custom BuildCheck registration in multi-project builds - #15555
Merged
baronfel merged 2 commits intoNov 17, 2026
Merged
Conversation
MattKotsenas
temporarily deployed
to
copilot-pat-pool
November 15, 2026 08:58 — with
GitHub Actions
Inactive
MattKotsenas
temporarily deployed
to
copilot-pat-pool
November 15, 2026 08:58 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
The reported Release suite has 13 failing tests, and the interrupted unchanged-source comparison requires human validation to determine whether they are baseline failures or regressions before approval.
No open issues 🎉
What changed in this PR
Fixes duplicate custom BuildCheck registrations in multi-project builds and prevents repeated telemetry rule IDs from causing build-completion failures. The separate configuration-ordering bug tracked by #15554 remains out of scope.
Changes:
- Reuses custom check registrations by loaded check type while applying each acquiring project’s configuration.
- Merges telemetry entries with repeated rule IDs using the existing aggregation logic.
- Adds regressions for repeated acquisition, enablement and severity changes, and telemetry aggregation.
| File | Description |
|---|---|
| src/Framework/BuildCheck/BuildCheckTracingData.cs | Merges repeated telemetry rule IDs instead of throwing on duplicate keys. |
| src/Framework.UnitTests/BuildCheckTracingEventArgs_Tests.cs | Tests telemetry aggregation and preservation of infrastructure statistics. |
| src/BuildCheck.UnitTests/BuildCheckManagerProviderTests.cs | Tests repeated acquisition and project-specific severity and enablement changes. |
| src/Build/BuildCheck/Infrastructure/BuildCheckManagerProvider.cs | Reuses custom check factory contexts by type to avoid duplicate callback registration. |
Review effort: Balanced
Reuse the existing factory context for each loaded custom check type, while applying every acquiring project's configuration. This avoids duplicate callbacks and stale severities without changing rule identity or adding a second registry. Add callback regressions for repeated acquisition, delayed enablement, warning-to-error changes, and disabling a previously enabled check.
MattKotsenas
force-pushed
the
bugfix/buildcheck-duplicate-registration
branch
from
November 17, 2026 17:55
53d58ea to
7d39616
Compare
baronfel
approved these changes
Nov 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issue(s): #15554 tracks a separate, pre-existing configuration-ordering bug that this PR does not fix.
Context
Projects can reference the same custom BuildCheck package through ordinary
PackageReferenceitems.When multiple projects acquire the package in one build, each acquisition currently appends another
callback registration. A two-project build reports the first project's violation once and the second
project's violation twice. Earlier registrations can also retain stale severity or enablement settings.
At build completion, tracing collects telemetry from those registrations. Constructing the tracing
dictionary throws for repeated rule IDs, stopping the build with
MSB4017and a duplicate-key exception.Changes Made
project's configuration without registering its callbacks again.
BuildCheckTracingData.MergeIn.disablement, and telemetry aggregation.
Compatibility
No public API, telemetry serialization format, assembly-loading policy, or configuration format changes.
Per-project severity and enablement remain configurable. The existing requirement for consistent custom
initialization configuration across projects remains in place.
Testing
BuildCheck tests pass in Debug and Release, including the added regressions. Multi-project integration
controls pass. The full patched Release run completed with 13 failed tests; its unchanged-source
comparison was interrupted by Defender quarantine and remains incomplete.