Description
Steps to Reproduce
Reference the System.ComponentModel.Composition NuGet in a project and use it:
<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-ios</TargetFramework>
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
<OutputType>Exe</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.ComponentModel.Composition" Version="6.0.0-preview.4.21253.7" />
</ItemGroup>
</Project>
"dotnet restore" will resolve to the xamarinios10
assembly, as can be seen in the generated project.assets.json file:
{
"version": 3,
"targets": {
"net6.0-ios13.6": {
"System.ComponentModel.Composition/5.0.0": {
"type": "package",
"compile": {
"ref/xamarinios10/_._": {}
},
"runtime": {
"lib/xamarinios10/_._": {}
}
}
},
The _._
file means "use the file shipped with Xamarin.iOS"
Previously the package restore would use the netstandard2.0
assembly:
{
"version": 3,
"targets": {
"net6.0-ios13.6": {
"System.ComponentModel.Composition/4.7.0": {
"type": "package",
"compile": {
"ref/netstandard2.0/System.ComponentModel.Composition.dll": {}
},
"runtime": {
"lib/netcoreapp2.0/System.ComponentModel.Composition.dll": {}
}
},
The behavior can be seen here: #11672 (comment)
This is presumably by design: https://github.com/dotnet/designs/blob/main/accepted/2021/net6.0-tfms/net6.0-tfms.md#compatibility-rules, but this needs to be verified. If it is by design, all NuGets that do the same thing (point to the assembly shipped with Xamarin.iOS) will have to be updated to provide an asset with a higher priority than xamarinios10
.
Current plan: update the TFM fallback rules (dotnet/designs#222).
Notes
- Both .NET 6 P4 and .NET 6 P6 work, while .NET 6 P5 doesn't. This is possibly because P5 has fixes P6 doesn't yet have.
- This applies to the System.Json NuGet as well, so it probably applies to all NuGets that point to assemblies shipped with Xamarin.iOS.
To be reverted once fixed: 99c7763