Converting Xamarin Native templates to .NET 6

.NET 6 is now officially out, but MAUI and the bits for .NET for Android and .NET for iOS are still in development. Some of the bits are already in preview now and are available for testing. The new SDK-style projects for Xamarin.Android and Xamarin.iOS is something I am personally very much looking forward to, as it removes a lot of clutter in the existing .csproj-files. The Xamarin Native templates naturally hasn’t been updated yet to use these, but here is how you can convert the templates by hand into the new SDK-style projects already now.

Note! These bits are still in preview and are subject to change, so the following might not be what they land on when they release in Q2 2022.


For Xamarin.Android, create a File -> New Android App (Xamarin) project.

The Android workload might have been installed when you installed the iOS workload, but if it didn’t, run this from the command line:

dotnet install workload android

Then, replace the content of the Android .csproj-file with this:

<Project Sdk="Microsoft.NET.Sdk">
    <PackageReference Include="Xamarin.AndroidX.AppCompat" Version="1.3.0" />
    <PackageReference Include="Xamarin.Google.Android.Material" Version="" />
    <PackageReference Include="Xamarin.Essentials" Version="1.6.1" />

Also, delete the AssemblyInfo.cs and the Resource.Designer.cs files. The .csproj has now been reduced down from 120 lines to just 11 lines. Nice!


For Xamarin.iOS it doesn’t quite seem like all the bits are in place yet. In theory you should have to do the following, but I was not able to deploy it to a device. Nonetheless, here is how you should be able to do it in theory:

Create a File -> New iOS App (Xamarin) project.

Then you’ll need to install the new iOS workload from the command line:

dotnet install workload ios

Then, replace the content of the iOS .csproj-file with this:

<Project Sdk="Microsoft.NET.Sdk">

This should at least work for testing on simulators. We will probably see a RuntimeIdentifier targeting actual hardware when Microsoft gets closer to release.

The first time you build the project, Visual Studio will probably try to download some packages and do some XCode validation. You may also have to change the Deployment Target version to the most current one (or match the one in your .csproj). You’ll also have to delete AssemblyInfo.cs, since this is not in use with the new SDK-style projects.

1 thought on “Converting Xamarin Native templates to .NET 6”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.