Condition Microsoft.Extensions.* package refs for net10+ and add Micr…#5209
Merged
DrewScoggins merged 1 commit intodotnet:mainfrom Apr 23, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
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+
FrameworkReferencetoMicrosoft.AspNetCore.Appso 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
previously approved these changes
Apr 22, 2026
f72945a to
063571a
Compare
…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>
063571a to
e38096c
Compare
Contributor
There was a problem hiding this comment.
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> |
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.
…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.