-
Notifications
You must be signed in to change notification settings - Fork 697
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
Add a project framework inference/parsing utility #3562
Merged
Merged
Conversation
This file contains 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
UWP projects actually use |
nkolev92
requested review from
cristinamanum,
dominoFire,
donnie-msft,
dtivel,
heng-liu,
kartheekp-ms and
rrelyea
as code owners
August 5, 2020 00:50
zkat
reviewed
Aug 5, 2020
nkolev92
force-pushed
the
dev-nkolev92-frameworkUtility
branch
from
August 5, 2020 18:07
02e2e8d
to
c453e22
Compare
zivkan
approved these changes
Aug 5, 2020
src/NuGet.Core/NuGet.Commands/Utility/MSBuildProjectFrameworkUtility.cs
Outdated
Show resolved
Hide resolved
zivkan
reviewed
Aug 5, 2020
src/NuGet.Core/NuGet.Commands/Utility/MSBuildProjectFrameworkUtility.cs
Outdated
Show resolved
Hide resolved
src/NuGet.Core/NuGet.Commands/Utility/MSBuildProjectFrameworkUtility.cs
Outdated
Show resolved
Hide resolved
…arseComponents more permissive
Co-authored-by: Andy Zivkovic <zivkan@users.noreply.github.com>
nkolev92
force-pushed
the
dev-nkolev92-frameworkUtility
branch
from
August 6, 2020 18:41
9e62fed
to
ff18e42
Compare
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.
Bug
Fixes: NuGet/Home#9871
Regression: No
Fix
Details: In 280abd3, NuGet started reading the platform information out of the internal properties. There is some inherent priority in those properties and they are not always perfect. For example, UWP projects will have a TargetFrameworkIdentifier of
.NETCoreApp
. NuGet has known how to interpret these for a while. Now we just need to incorporate,TargetPlatformIdentifer
andTargetPlatformVersion
into the mix.To do that, we'll introduce a new utility,
GetProjectFramework
, that takes all these values and spits out aNuGetFramework
.Internally the existing utility has been refactored so that the same codepaths are hit. The public API hit is minimal ;)
Caveats
There's a larger impact of this PR.
In new .NET 5 SDKs, think NET5.0 P8, from the 5 properties NuGet reads, the ones that are not necessary, are cleared, however in .NET 5 P7 and earlier (that includes the complete 3.0, 3.1 SDK line), the
TargetPlatformInformation
&TargetPlatformVersion
may default to something likeWindows
andv7.0
and we'd end up with a framework such asnet5.0-windows7.0
in .NET 5 cases (think NuGet.Client), or an exception (in netcoreapp3.1 cases) saying thatTargetPlatformIdentifier
is only allowed. Note that the last case can easily happen in commandline scenarios where the customer ends up with an upgrade nuget, but not sdk.While this scenario is not recommended, I imagine it'll be common enough where we have to handle it.
After a discussion with @zivkan and @zkat we agreed to change ParseComponents to fit the requirements that we have.
Specifically that it having a precedence order of the params.
Other options considered:
Note that given that ParseComponents hasn't shipped, we can easily revert the API.
Testing/Validation
Tests Added: Yes
Reason for not adding tests:
Validation: