Improve the handling of platform-suffixed target frameworks #306
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.
We previously (ab)used the TargetFrameworkMoniker of a project as a default/fallback target framework to use whenever the TargetFramework metadata was not present for a particular PackageFile.
This broke down in .NET5+ when platform-suffixed TFs such as "net7.0-windows" now need the target platform version, in addition to the TF< which, furthermore, can no longer be recreated as a nuget framework from the TFM alone, since it also contains the TargetPlatformIdentifier.
So rather than complicating the previous single metadata value with three (TFM, TPM and a boolean on whether the original TF had a platform suffix or not), we instead normalize this up-front in all projects via a new target, and set this as PackTargetFramework. We then proceed to use this in a new more intention-revealing metadata item, DefaultTargetFramework, which is now much more obvious than "leveraging" the TFM name.