[Bug] Xamarin Page and View Templates break MAUI Apps
See original GitHub issueDescription
When adding a ContentView or ContentPage to a .NET MAUI app using Visual Studio, it uses the Xamarin templates. Once you do this, the .NET MAUI app will no longer build.
I’m not sure if this is a MAUI issue or a Visual Studio 2022 issue - however, the build fails at the .NET CLI too.
Steps to Reproduce
- Build a new .NET MAUI app
- Using Visual Studio, add a ContentView or ContentPage
- Try to build and run your .NET MAUI app
Expected Behavior
The app builds and runs
Actual Behavior
Multiple compiler warnings are thrown for The name 'InitializeComponent' does not exist in the current context
Basic Information
- Version with issue: .NET MAUI Preview 9
- Last known good version: NA
- IDE: Visual Studio 2022 17.0.0.0 Preview 7
- Platform Target Frameworks:
- iOS:
- Android:
- UWP:
- Android Support Library Version:
- Nuget Packages: None
- Affected Devices: All
Screenshots
Reproduction Link
Workaround
With limited success, removing the views or pages added with the Xamarin templates, deleting the bin and obj folders (specifically obj) and cleaning/rebuilding the solution, you can run your app. This workaround does not work consistently though - probably because I have been unable to extricate all the of the Xamarin references.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Troubleshoot known issues - .NET MAUI
NET Multi-platform App UI (.NET MAUI), and how you can solve or work around them. The .NET MAUI repository also details some known...
Read more >I updated a Xamarin Forms project to Maui - Brad Dean
For my sample project I just created the blank Xamarin Forms Template. It's a very simple app so we won't be seeing how...
Read more >Did .NET MAUI Ship Too Soon? Devs Sound Off on ' ...
As I've used to be a Xamarin dev I can tell MAUI won't be stable for a year. I've worked deeply on an...
Read more >Create multi-page .NET MAUI apps with tab and flyout ...
Learn Live - Create multi-page .NET MAUI apps with tab and flyout navigation. 8.7K views · Streamed 9 months ago ...more ...
Read more >Prism for .NET MAUI - Public Beta - Dan Siegel
Dan Siegel - Building Better Apps - Ok the name kind of gives it away, but Prism for .NET MAUI is now available...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Eep! I think if the Xamarin.Forms item templates for ContentView and ContentPage show up then we need to make sure those get hidden from .NET MAUI apps. .NET MAUI does have its own ContentView and ContentPage item templates. For some reason in VS I see only the Xamarin.Forms versions but in the command line (
dotnet new ...
) I see the .NET MAUI ones.whenever i create page with vs2022 then i have to remove the first line which contains
<?xml version="1.0" encoding="UTF-8"?>
and also the code for this page from csproj file. then it works fine.