Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make private runtime-only dependencies on .NET Standard 2.0. #11109

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

teo-tsirpanis
Copy link
Contributor

Context

Since #6148 we produce only reference assemblies for .NET Standard 2.0, which means that several of the our NuGet packages' dependencies when targeting .NET Standard 2.0 are unused.

Changes Made

The project files for Microsoft.Build.Framework, Utilities.Core and Tasks were updated to apply PrivateAssets="all" to all package references that are not exposed in the package's public API, when targeting .NET Standard 2.0.

Testing

I ran dotnet pack on these projects and validated manually that on .NET Standard 2.0, Microsoft.Build.Framework has zero dependencies, Utilities.Core depends only on Framework, and Tasks depends only on the previous two.

Because Roslyn keeps some internal APIs in reference assemblies, these reference assemblies still reference some assemblies whose respective package is not depended upon. I manually validated with ILSpy that the types in these assemblies are used only by internal APIs.

Notes

This is going to be a (minor) source-breaking change if a .NET Standard 2.0 project uses APIs from on one of the removed packages and transitively depended on it. They will have to directly depend on them, and it's not the first time we do a change like this (#9055).

I don't think that this is a binary-breaking change because the .NET Standard 2.0 binaries are not being used at runtime.

The reference to immutable collections is surfaced to `Framework`.
This lightens the NS2.0 reference assembly.
@rainersigwald
Copy link
Member

Nice, I've been planning to do something like this (and likely even going further). Will look shortly.

@teo-tsirpanis
Copy link
Contributor Author

and likely even going further

Let me know how further this can go, happy to do it now or in a subsequent PR.

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.

2 participants