New .Net MAUI App project throws 'The name 'InitializeComponent' does not exist in the current context' build errors

I faced the same issue and looks like when I created a ContentPage in VS its still pointing to Xamarin Forms. After changing namespace to MAUI, I updated the Build Action(RightClick on Xaml Page>>Properties>>BuildAction) of XAML Page to MauiXaml and it worked for me.


  1. Close VS2022
  2. Open VS2022
  3. Open project with menu VS2022(File - Open - Project...)

The path to the project I created is c:\develop\c#...... as soon as I copy the project to a folder that doesn't contain 'c#' it works. This clearly causes some parsing in the background to fail.