Upgrade Xamarin Forms Cross Platform Library from NetStandard2.x to Net7

Tony Pitman 41 Reputation points
2023-03-27T20:38:12.3+00:00

I am trying to use the Acr.UserDialogs nuget package. I was using an older version with an older build of my Xamarin.Forms app for Android.

I have a library that uses it that is cross platform. When I try to upgrade the Acr.UserDialogs package it tells me that it isn't compatible with NETStandard 2.1 and that I need to upgrade to at least net6.

When I go to the properties of the library the only options are NetStandard or Net Core 3 or 5, both of which are out of support and the Acr.UserDialogs needs 6 or later anyway.

I have Visual Studio 2022 for Mac. I have the latest version that includes net6 and net7.

Below is the output of my dotnet --info command.

If I try to manually modify the library's project file to net7.0 (as I have in other blazor projects), it says it can't find it.

How do I upgrade a Xamarin.Forms cross platform library project from netstandard 2.x to net 7?

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,297 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,415 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Alessandro Caliaro 4,181 Reputation points
    2023-03-27T20:48:00.03+00:00

    I think the last version is for Maui. Stay in version 7


  2. Bruce (SqlWork.com) 56,931 Reputation points
    2023-03-27T23:02:36.2133333+00:00

    not sure your issue. net 7 can use netstandard 2.0 libraries. a .net core app can be built with an earlier version libraries.

    if you are building a library for .net 7, the library should target .net 2.0, net 6.0 or net 7.0. libraries can only reference libraries of same target or lower.

    Acr.UserDialogs appears to be a dead project (died: March 5, 2021), but has a .net 6 version (version 8) and .net 2.0 version (version 7) as Acr.UserDialogs is dead, you may need to fork and update, though you may want to pick a replacement.

    if you want to stay on Xamarin forms, then I'd stick with net 6 LTS, as it is supported 6 months longer than net 7 (end of life: May 14, 2024) and you will probably have better compatibility than with net 7.

    if you want support, in 13 months you need to off Xamarin forms anyway (end of life May 1, 2024). You should start your port to Maui pretty soon. this Nov, you should start your net 8 migration.

    in summary if you need a quick and dirty port, use .net 6. if you need long range, then net 7 and Maui, with an end of year upgrade to net 8.