Description
Related: #22901 (comment)
It is becoming more and more common for newer versions of packages (particularly for new major versions of them) to drop support for unsupported Target Frameworks. Even packages produced from dotnet itself does this. An example of this is the following:
I have a Package Foo v1.0.0 which originally supported net6.0. After a few years, I ship Foo v2.0.0 which drops support of net6.0 as that is out of support now and instead I target net8.0 now, but I still want my surface area of Foo (net8.0) to be compatible with the previous one I shipped (net6.0) in order to not break my existing customers that are using package 1.0.0.
Like explained in the case above, a lot of developers will care about not making breaking changes to their API even when dropping support of target frameworks, as they will still want that other libraries that consumed their 1.0.0 version would still work in an app that targets net8.0 and that lifts Foo to v2.0.0. While PackageValidation feature will work in Foo today, you are currently not able to do baseline package validation (meaning ensuring you don't break a previously shipped API), since that relies on the new package never dropping support of all TFMs. The way it works today if you don't drop TFMs is that the following comparisons are made which ensures you maintain compatibility:
- (baseline package) net6.0 compared to (new package) net6.0
- (new package) net6.0 compared to (new package) net8.0
This is the way we ensure today that you are not breaking old APIs, but this feature request is asking to see if we can support this while dropping the net6.0 in the new package so that instead we compare:
- (baseline package) net6.0 compared to (new package) net8.0
Proposal
One way to do this, would be to add a special set of properties that allow you to specify this remapping when performing baseline validation like:
<EnablePackageValidation>true</EnablePackageValidation>
<PackageValidationBaselineVersion>1.0.0</PackageValidationBaselineVersion>
<PropertyGroup>
<ItemGroup>
<!-- new -->
<PackageValidationBaselineTargetFrameworkMapping Include="net6.0" MapTo="net8.0" />