Make private runtime-only dependencies on .NET Standard 2.0. #11109
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.
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
andTasks
were updated to applyPrivateAssets="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 onFramework
, andTasks
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.