android: [net6-android] A package with netstandard2.0, monoandroid10.0 and net6.0-android should not favor monoandroid10.0

Steps to Reproduce

Expected Behavior

The build passes as Class1 is defined only in net6.0-android30.0 in the ClassLibrary15 package.

Actual Behavior

The build fails where Class1 is not defined, because monoandroid10.0 is favored over net6.0-android30.0 even if the app is using net6.0-android. Note that the issue does not happen if netstandard2.0 is not included in the package.

Version Information

6.0.100-preview.4.21215.1

Additional info

This issue is similar to https://github.com/xamarin/xamarin-android/issues/5857, but with the monoandroid10.0 target framework added to the list.

This issue also looks similar to https://github.com/xamarin/xamarin-android/issues/5819, but in the context of package references, not projects references.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 1
  • Comments: 16 (8 by maintainers)

Commits related to this issue

Most upvoted comments

My plan right now for this is:

  1. The NuGet team implements this: https://github.com/dotnet/designs/pull/210
  2. I delete this Microsoft.Android.Sdk.NuGet.targets file completely:

https://github.com/xamarin/xamarin-android/blob/c60635bf2161f6e3b2d74ebcd7a3f96deef956a2/src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.NuGet.targets#L23-L35

  1. Hope everything works? (๐Ÿ˜„ if not, look into it more)

In the mean time, if you need this to work, you might try editing Microsoft.Android.Sdk.NuGet.targets locally and see if some combination works. I wonder if listing net6.0-android in $(PackageTargetFallback) with no 30.0 would help. If you figure something out, let me know.

What we have now is basically several hacks that enable legacy Xamarin.Forms packages to work in .NET 6, but itโ€™s definitely not correct yet.