Skip to content

Condition Microsoft.Extensions.* package refs for net10+ and add Micr…#5209

Merged
DrewScoggins merged 1 commit intodotnet:mainfrom
DrewScoggins:fix-extensions-inband-net10
Apr 23, 2026
Merged

Condition Microsoft.Extensions.* package refs for net10+ and add Micr…#5209
DrewScoggins merged 1 commit intodotnet:mainfrom
DrewScoggins:fix-extensions-inband-net10

Conversation

@DrewScoggins
Copy link
Copy Markdown
Member

…osoft.AspNetCore.App FrameworkReference

The Microsoft.Extensions.* libraries (Configuration, Configuration.Binder/Json/Xml, Caching.Memory, DependencyInjection, Http, Logging, Logging.EventSource) are now in-band in the Microsoft.AspNetCore.App shared framework for net10.0+. Direct PackageReferences raise NU1510 (promoted to error by TreatWarningsAsErrors), and without the framework reference the compiler fails with CS0246 for IConfiguration, ObjectFactory, IChangeToken, etc.

Follows the pattern from #5196 (which handled Microsoft.Extensions.Primitives, in-band in Microsoft.NETCore.App), and adds a FrameworkReference to Microsoft.AspNetCore.App for net10.0+ so the in-band assemblies resolve.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the microbenchmarks project’s dependencies to accommodate .NET 10+ SDK “package pruning” (NU1510) for Microsoft.Extensions.* assemblies, by avoiding direct PackageReferences on net10.0+ and instead relying on framework-provided assemblies.

Changes:

  • Condition Microsoft.Extensions.* PackageReferences to apply only for TFMs below net10.0.
  • Add a net10.0+ FrameworkReference to Microsoft.AspNetCore.App so Microsoft.Extensions.* types resolve for those TFMs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +127 to +131
<!-- For net10.0+, the Microsoft.Extensions.* libraries used here are in-band in the
Microsoft.AspNetCore.App shared framework. Reference the framework so the types resolve. -->
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net10.0'))">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
LoopedBard3
LoopedBard3 previously approved these changes Apr 22, 2026
…es app-local

Starting with .NET 10, NuGet's package-pruning feature (NU1510) flags
direct PackageReferences to packages that are now in-band in the
Microsoft.AspNetCore.App shared framework (Microsoft.Extensions.Configuration,
.DependencyInjection, .Caching.Memory, .Http, .Logging, etc.) as well as some
that have moved into Microsoft.NETCore.App (System.Formats.Cbor). With
TreatWarningsAsErrors this fails the build for net10.0+/net11.0+ TFMs.

Rather than removing those PackageReferences and adding a FrameworkReference
to Microsoft.AspNetCore.App, set RestoreEnablePackagePruning=false (and
suppress NU1510). This keeps the assemblies app-local, which is required for
BenchmarkDotNet's corerun toolchain: that toolchain points at a CoreRoot under
shared/Microsoft.NETCore.App/... which does not contain Microsoft.AspNetCore.App
or its assemblies, so an in-band/FrameworkReference approach would break perf
runs that use --corerun against a runtime CoreRoot.

Verified locally with benchmarks_ci.py -f net11.0 (build) and a smoke run of
ActivatorUtilitiesBenchmark.* under --corerun.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 22, 2026 20:05
@DrewScoggins DrewScoggins force-pushed the fix-extensions-inband-net10 branch from 063571a to e38096c Compare April 22, 2026 20:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the microbenchmarks project’s restore/build settings to avoid .NET 10+ NuGet package-pruning failures (NU1510) when referencing Microsoft.Extensions.* packages.

Changes:

  • Disables NuGet package pruning for MicroBenchmarks.csproj.
  • Suppresses NU1510 during build/restore.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +24 to +25
<RestoreEnablePackagePruning>false</RestoreEnablePackagePruning>
<NoWarn>$(NoWarn);NU1510</NoWarn>
Comment on lines +19 to +25
<!-- Disable NuGet package pruning (.NET 10+) so Microsoft.Extensions.* and other
in-band but still-published packages remain app-local. The benchmarks are run
via BenchmarkDotNet's corerun option against a NetCoreApp CoreRoot that does
not include the Microsoft.AspNetCore.App shared framework, so app-local copies
of these assemblies are required. Also suppresses NU1510. -->
<RestoreEnablePackagePruning>false</RestoreEnablePackagePruning>
<NoWarn>$(NoWarn);NU1510</NoWarn>
@DrewScoggins DrewScoggins merged commit 542b668 into dotnet:main Apr 23, 2026
9 of 78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants