Xamarin.Android9.0 target should be chosen over netstandard2.0 target by Android test project
AArnott opened this issue · 7 comments
When I have a multi-targeting library that offers netstandard2.0 and Xamarin.Android9.0 targets, and I reference that from a Xunit Devices Android project, I expect the Xamarin.Android9.0 target to be used by the android app since it's platform specific, which should be preferred, I think.
But in the attached minimal repro we see the test fails because the netstandard2.0 build of the library is selected.
Am I misunderstanding something? How can I get the library's android target to be used in android projects that reference it?
I also notice that packing the multi-targeting library fails with:
1>C:\Program Files\dotnet\sdk\3.1.302\Sdks\NuGet.Build.Tasks.Pack\buildCrossTargeting\NuGet.Build.Tasks.Pack.targets(198,5): error NU5027: Invalid target framework for the file 'C:\Users\andarno\source\repos\XamarinTest\XamarinTest\bin\Debug\xamarin.android9.0\XamarinTest.dll'.
Switching the TFM from Xamarin.Android9.0
to MonoAndroid9
solves both problems. If that's the supported way, why is Xamarin.Android
listed in the README instead of monoandroid
?
I have the same problem with iOS. Xamarin.iOS
didn't get picked up by the iOS project. But xamarinios
did (no period).
This seems like a NuGet bug. The extras has nothing to do with TFM selection.
I wonder. The documented list of TFMs (if you scroll down far enough) include a table that lists monoandroid
and xamarinios
. It does not list the two that your README lists. So NuGet is acting consistently with the MS published docs as far as I can tell. Which begs the question: where did you get the Xamarin.iOS
and Xamarin.Android
TFMs that you're using?
Xamarin.iOS comes from https://docs.microsoft.com/en-us/xamarin/cross-platform/app-fundamentals/nuget-manual#nuget-package-xamarin-profiles
I don't remember where I saw Xamarin.Android.
What do you think about updating your README to reflect what currently works today, and we can pursue filing bugs against nuget to either honor the doc you linked to, or to correct the doc to reflect today's behavior?