How do you target the same NuGet package, with different versions, within the same .Net MAUI project?

303 views Asked by At

I'm seeing the following NuGet version conflict error after upgrading a Xamarin Forms library project to .Net7.0 MAUI;

"Version conflict detected for Xamarin.Android.Support.Annotations.

Install/reference Xamarin.Android.Support.Annotations 28.0.0.3 directly to project Library_Upgrade to resolve this issue.

Library_Upgrade -> Xamarin.Azure.NotificationHubs.Android 1.1.1 -> Xamarin.Android.Support.v7.AppCompat 28.0.0.3 -> Xamarin.Android.Support.Annotations (= 28.0.0.3)

Library_Upgrade -> Xamarin.Android.Support.Collections 28.0.0.1 -> Xamarin.Android.Support.Annotations (= 28.0.0.1)."

It seems two packages need different versions of Xamarin.Android.Support.Annotations (28.0.0.3 and 28.0.0.1).

If I do what the error suggests and install 28.0.03 directly, it doesn't install the package as the dependency on 28.0.0.1 stops the update.

1

There are 1 answers

0
Lewis Herbert On

Have you tried removing:
Xamarin.Azure.NotificationHubs.Android and Xamarin.Android.Support.Collections from your project.

Then try to install:
Xamarin.Android.Support.Annotations version 28.0.0.3

Finally reinstall:
Xamarin.Azure.NotificationHubs.Android and Xamarin.Android.Support.Collections to your project

This should force the installation of the required version of Xamarin.Android.Support.Annotations (28.0.0.3) for both packages, and resolve the version conflict.