improve nuget package detection with SDK-managed packages #11127
+1,155
−33
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.
Consider the following example:
A repo contains a
global.json
file requiring the .NET SDK version8.0.303
. A project in that repo has a dependency onSystem.Text.Json/8.0.0
(either transitively or directly, it doesn't matter.)When we detect dependencies, we run a
restore
operation, but the SDK takes special steps. During that operation, it sees the reference toSystem.Text.Json
and realizes it has a newer copy, so it removes the reference.The end result is that we don't report
System.Text.Json
as a reference because:(Doing some manual checking, the version of
System.Text.Json
that the8.0.303
SDK is using as a replacement is8.0.4
. This is important for later.)If we then try to perform an update on
System.Text.Json/8.0.4
=>8.0.5
we'll fail because that dependency wasn't reported.This PR fixes that behavior.
When the special package is removed, we detect that then perform a lookup to see that the version of
System.Text.Json
that ships with the SDK8.0.303
just so happens to match exactly with the NuGet packageSystem.Text.Json/8.0.4
. We then re-insert that dependency back into our reporting, because that's the equivalent package.This way when we try to update
System.Text.Json
to version8.0.5
, we can correctly see that the dependency does exist as version8.0.4
so the update then to8.0.5
succeeds.This was accomplished by adding a submodule to the
dotnet/core
repo and parsing and correlating severalreleases.json
files with markdown files that list the relevant packages. The end result is a 6MB JSON file that contains all of the SDK package mappings. This large mapping file is generated on build, so no manual steps need to be performed (and no huge file was added).