Reputation: 3716
I have converted a Xamarin project to MAUI project using Upgrade Assistant as per this blog. First I upgraded solution, then I upgraded the android and ios projects. After that I build my solution but I get the below errors.
Error NETSDK1047 Assets file 'C:\Users\SREEJITH\source\repos\MAUIDemo\MAUIDemo\MAUIDemo.iOS\obj\project.assets.json' doesn't have a target for 'net6.0-ios/ios-arm64'. Ensure that restore has run and that you have included 'net6.0-ios' in the TargetFrameworks for your project. You may also need to include 'ios-arm64' in your project's RuntimeIdentifiers.
MAUIDemo.iOS C:\Program Files\dotnet\sdk\7.0.306\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 266
Error CS0234 The type or namespace name 'Forms' does not exist in the namespace 'Xamarin' (are you missing an assembly reference?)
MAUIDemo.Android (net6.0-android) C:\Users\SREEJITH\source\repos\MAUIDemo\MAUIDemo\MAUIDemo.Android\MainActivity.cs 11 Active
Error CS0234 The type or namespace name 'Content' does not exist in the namespace 'MAUIDemo.Android' ...
Error CS0234 The type or namespace name 'Essentials' does not exist in the namespace 'Xamarin' ...
Error CS0234 The type or namespace name 'Forms' does not exist in the namespace 'Xamarin' ...
Error CS0103 The name 'LoadApplication' does not exist in the current context MAUIDemo.Android (net6.0-android) C:\Users\SREEJITH\source\repos\MAUIDemo\MAUIDemo\MAUIDemo.Android\MainActivity.cs 19 Active
...
Screenshot:
I have a few questions related to this:
I upgraded the solution, android and iOS projects. Is solution upgrade is enough or do we need to upgrade the android and iOS projects?
When I create a new MAUI project, I found there is a Platforms
folder and on that I found Android and iOS sub folders. But when upgrade no such folders are created on my side, should I create it manually?
Below is the project structure of a MAUI project created. Like that do I need to create all the files and folders?
Update
Below issues are currently I am facing:
- Error : XamlC error XFC0000 : Cannot resolve type "ContentPage".
- Error : XamlC error XFC0000 : Cannot resolve type "Frame".
- Error : XamlC error XFC0000 : Cannot resolve type "Application".
- Project targets 'net6.0-android;net6.0-ios'. It cannot be referenced by a project that targets 'MonoAndroid,Version=v13.0'.
- Project targets 'net6.0-android;net6.0-ios'. It cannot be referenced by a project that targets 'Xamarin.iOS,Version=v1.0'.
- Project is not compatible with monoandroid13.0 Project supports: net6.0-android31.0 (.NETCoreApp,Version=v6.0) net6.0-ios16.1 (.NETCoreApp,Version=v6.0)
- Project is not compatible with xamarinios10 Project supports: net6.0-android31.0 (.NETCoreApp,Version=v6.0) net6.0-ios16.1 (.NETCoreApp,Version=v6.0)
- Version conflict detected for Xamarin.AndroidX.Browser. Install/reference Xamarin.AndroidX.Browser 1.4.0.1 directly to project to resolve this issue. Microsoft.Maui.Dependencies 6.0.553 -> Xamarin.AndroidX.Browser (>= 1.4.0.1) Xam.Plugin.HtmlLabel 5.1.0 -> Xamarin.Essentials 1.7.0 -> Xamarin.AndroidX.Browser (>= 1.3.0.5 && < 1.4.0).
- The target platform must be set to Windows (usually by including '-windows' in the TargetFramework property) when using Windows Forms or WPF, or referencing projects or packages that do so.
Upvotes: 2
Views: 880
Reputation: 21321
Known issue: Bug: MAUI-Template: net6.0-ios is missing RuntimeIdentifier ios-arm64.
To fix an existing project, add the following to your project's .csproj
file:
<PropertyGroup Condition="$(TargetFramework.Contains('-ios'))">
<RuntimeIdentifier>ios-arm64</RuntimeIdentifier>
</PropertyGroup>
UPDATE:
For a Xamarin Forms to Maui upgrade using Upgrade Assistant, it is the iOS
project that needs this identifier.
- I upgraded the solution, android and iOS projects. Is solution upgrade is enough or do we need to upgrade the android and iOS projects?
Upgrading the solution upgrades all the projects. Do NOT need to also run upgrade on each project.
- Should I create Platforms folder manually.
No. If you later add another file for a platform, you will add it where the Upgrade Assistant put your files for that platform.
- Project structure.
The structure created by Upgrade Assistant has everything needed. It is not necessary to match the structure created by a new Maui Project Template.
ALTERNATIVE FIX
You could move the upgraded source files into a new Maui project. This will avoid the problem. And gives you a layout the same as anyone else who creates a new Maui project.
To make a new solution from your existing Xamarin Forms solution:
Upvotes: 4