Search code examples
xamarin.formsupgrademauivisual-studio-2022

Upgrade from Xamarin Forms to Maui disables selection of emulator or connected device


I'm trying to upgrade from Xamarin.Forms to .Net Maui using the .NET Upgrade Assistant extension in visual studio 2022. I started with a simple xamarin forms project that only runs on android (Used the "Android xaml app (Xamarin Forms)" template).

Before I start the upgrade I see the emulator when I set the android project as startup project: enter image description here

I can also select other emulators and an external device if I want to. I then right click on the Android project and click upgrade, select an In-Place project upgrade and set .Net 7.0 as target framework. AFter this upgrade the emulators and the external device can not be selected anymore. When I also upgrade the common project and fix some build errors, I can run the project. The emulator does starts up, but there is no way to select another emulator or using the external device (This last one is blocking me). I did also create a dotnet maui project from scratch. all works fine there (No problems selecting my device) Anyone has an idea on what could be the cause of this and how I can fix this?


Solution

  • Looks like there are still issues when upgrading the Android and shared xamarin projects. What worked for me is.

    • Only upgrade the shared xamarin project. Use "Side by side project upgrade" instead of "In-place project upgrade".
    • Click on the newly created project and set OutputType to Exe (was library)
    • If you set this project file as startup project you'll see the emulators and external device are available

    Note: to continue a Platforms and resources folder has to be created and some stuff (like for example the AndroidManifest.xml file) can be copied from the Android xamarin project into the correct location. Just look at a default Maui application on how it is structured.