Repository navigation
Condition framework-provided package references for .NET 11 - #7915
Merged
Merged
Conversation
Retain Microsoft.Extensions package dependencies for older targets while avoiding redundant references and NU1510 on net11.0. Document pruning checks for future target framework additions. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
π’ Approval recommended
No active review issues are reported for the .NET 11 package-reference conditioning changes.
No open issues π
What changed in this PR
Following the .NET 11 targeting added in #7912, this PR conditions redundant framework-provided package references to avoid NU1510 restore warnings while preserving dependencies for older targets.
Changes:
- Adds .NET 11 compatibility conditions to 32 package references across libraries, shared code, tests, and engineering tooling.
- Preserves existing package references for older target frameworks without suppressing warnings.
- Documents package-pruning checks for future target-framework additions.
| File | Description |
|---|---|
| test/βLibraries/βMicrosoft.Extensions.Telemetry.Tests/βMicrosoft.Extensions.Telemetry.Tests.csproj | Conditions the Options reference. |
| test/βLibraries/βMicrosoft.Extensions.Resilience.Tests/βMicrosoft.Extensions.Resilience.Tests.csproj | Conditions DependencyInjection.Abstractions. |
| test/βLibraries/βMicrosoft.Extensions.AI.Integration.Tests/βMicrosoft.Extensions.AI.Integration.Tests.csproj | Conditions the Options reference. |
| src/βShared/βShared.csproj | Conditions dependency injection and logging abstractions. |
| src/βLibraries/βMicrosoft.Extensions.Telemetry.Abstractions/βMicrosoft.Extensions.Telemetry.Abstractions.csproj | Conditions Options and logging abstractions. |
| src/βLibraries/βMicrosoft.Extensions.ServiceDiscovery.Dns/βMicrosoft.Extensions.ServiceDiscovery.Dns.csproj | Conditions four framework-provided references. |
| src/βLibraries/βMicrosoft.Extensions.ServiceDiscovery.Abstractions/βMicrosoft.Extensions.ServiceDiscovery.Abstractions.csproj | Conditions five framework-provided references. |
| src/βLibraries/βMicrosoft.Extensions.Options.Contextual/βMicrosoft.Extensions.Options.Contextual.csproj | Conditions the Options reference. |
| src/βLibraries/βMicrosoft.Extensions.ObjectPool.DependencyInjection/βMicrosoft.Extensions.ObjectPool.DependencyInjection.csproj | Conditions the Options reference. |
| src/βLibraries/βMicrosoft.Extensions.Diagnostics.ExceptionSummarization/βMicrosoft.Extensions.Diagnostics.ExceptionSummarization.csproj | Conditions DependencyInjection.Abstractions. |
| src/βLibraries/βMicrosoft.Extensions.DependencyInjection.AutoActivation/βMicrosoft.Extensions.DependencyInjection.AutoActivation.csproj | Conditions Hosting.Abstractions. |
| src/βLibraries/βMicrosoft.Extensions.DataIngestion/βMicrosoft.Extensions.DataIngestion.csproj | Conditions Logging.Abstractions. |
| src/βLibraries/βMicrosoft.Extensions.Compliance.Abstractions/βMicrosoft.Extensions.Compliance.Abstractions.csproj | Conditions DependencyInjection.Abstractions. |
| src/βLibraries/βMicrosoft.Extensions.Caching.Hybrid/βMicrosoft.Extensions.Caching.Hybrid.csproj | Conditions caching, logging, and Options references. |
| src/βLibraries/βMicrosoft.Extensions.AsyncState/βMicrosoft.Extensions.AsyncState.csproj | Conditions DependencyInjection.Abstractions. |
| src/βLibraries/βMicrosoft.Extensions.AmbientMetadata.Build/βMicrosoft.Extensions.AmbientMetadata.Build.csproj | Conditions Hosting.Abstractions. |
| src/βLibraries/βMicrosoft.Extensions.AmbientMetadata.Application/βMicrosoft.Extensions.AmbientMetadata.Application.csproj | Conditions Hosting.Abstractions. |
| src/βLibraries/βMicrosoft.Extensions.AI/βMicrosoft.Extensions.AI.csproj | Conditions caching, dependency injection, and logging abstractions. |
| eng/βTools/βDiagConfig/βDiagConfig.csproj | Conditions Logging.Abstractions for the engineering tool. |
| docs/βadding-a-target-framework.md | Documents framework-provided package checks and conditional references. |
Review effort: Balanced
Collaborator
π Good job! The coverage increased π
Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1662848&view=codecoverage-tab |
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.
After #7912 added net11.0 targeting, restoring Telemetry.Tests with warnings treated as errors fails with NU1510 for Microsoft.Extensions.Options. .NET 11 now includes nine Microsoft.Extensions abstraction assemblies in Microsoft.NETCore.App, making their explicit package references redundant.
Condition 32 references across libraries, shared code, tests, and engineering tooling using
!IsTargetFrameworkCompatible(..., 'net11.0'). This preserves existing dependencies for older targets without suppressing NU1510. Include multi-target libraries whose legacy targets mask the diagnostic, and document pruning checks for future TFM additions.Validation
The full test command encountered an unrelated ObjectPool net472 TRX-reporting failure at a 261-character artifact path. The same 16 tests and all report formats pass with shorter output paths. DiagConfig builds without NU1510, but its standalone warnings-as-errors restore still encounters the existing NU1506 duplicate System.CommandLine entry; ordinary compilation also reports existing RT0000 and S1871 warnings.
Microsoft Reviewers: Open in CodeFlow