Remove Microsoft.Extensions.Caching.Memory reference since it is platform provided#2017
Remove Microsoft.Extensions.Caching.Memory reference since it is platform provided#2017nkolev92 wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2017 +/- ##
=======================================
Coverage 92.12% 92.12%
=======================================
Files 438 438
Lines 15044 15044
Branches 2488 2488
=======================================
Hits 13859 13859
Misses 731 731
Partials 454 454 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
That breaks the build. |
|
I see the problem. The ASP.NET framework ref is what actually provides By adding the framework ref explicitly, you get a broader set of prunable packages. I'll file some issues to improve this behavior. We had talked about a warning to help identify this scenario at build time. I'll file some issues and improve the documentation. |
|
Okay, I think that's a reasonable change for this project, because Though I wonder what the guidance would be for low-level libraries. For example, a hypothetical YAML parser that uses only Base64UrlTextEncoder, which is defined in the The NU1510 warning that is emitted when I remove the warning suppression: <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1"
Condition="'$(TargetFramework)' == 'net8.0'">Is:
This looks questionable, because:
The implication of how this warning works today is that package owners need to choose between:
I think many package authors choose 3 for good reasons. The warning should be a suggestion because its message reads "likely unnecessary," and low-level libraries are a legitimate use case to suppress it. In general, keeping the reference should be fine, since it will be pruned anyway and is harmless. I'd love to hear your thoughts on this. |
|
Perhaps I'm misunderstanding all of this. https://stackoverflow.com/questions/64478618/what-does-frameworkreference-include-microsoft-aspnetcore-app-actually-do, suggests that I also noticed that nuget.org doesn't list framework dependencies, although they do appear in the |
|
FrameworkReferences are transitive already. So we're not really adding anything new by explicitly specifying the FrameworkReference. |
Then why do I need to add it in |
|
Transitive framework reference application and pruning are both restore applied. Currently, pruning affects framework reference application by virtue of picking packages. NuGet/Home#14920 option 1 touches on it. |
|
Thanks for the clarification and for opening an issue. Could you please address my concerns in #2017 (comment), especially about low-level libraries? At work, I'm part of a team that builds many of those, and discussions keep coming up about whether we should keep references to System/Microsoft libraries or add framework references instead. Some examples here and here. My point of view has always been to keep these explicit references, but now I'm not so sure anymore. Would it be recommended to replace them all with framework references? Is there any guidance/docs, or are there limitations I should be aware of before doing so? And are the oddities regarding NU1510 tracked anywhere? Particularly, I find the message "will not be pruned" very confusing. As a developer, my understanding of the concept of pruning is: what will be removed from the set of libraries my project depends on, not what the restore command does internally to validate the graph. |

Follow up to https://devblogs.microsoft.com/dotnet/nuget-package-pruning-in-dotnet-10/?commentid=22975#comment-22975.
QUALITY CHECKLIST
Changes implemented in codeAdapted testsExisting tests should pass just fine. Not audit issues reported.Documentation updated