-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation for Multi-Project setup. #7426
Comments
+1 on this. Would really appreciate some documentation. It is very difficult to maintain in a single project and most of us migrating from xamarin with an existing CI/CD environment would prefer to achieve the same project structure in MAUI as well. Although I am able to build and run the given repo sample (with slight changes) successfully for As soon as I set
Shared project containing xaml views:
iOS project:
Droid project:
|
+1 This would greatly help the migration story since most xamarin apps are multi project setups. |
+1 UP |
++ 1 UP Hey @jfversluis Why is there no response on that issue? We want to keep the Xamarin.Forms architecture as Multi-project solution, even after migration to MAUI. |
@ericbrunner if that is what you want, you should be able to use the .NET Upgrade Assistant which will help you with both that migration as well as doing that with multiple projects. |
+1 UP please document creating multi-project setup for new apps, too, not only migrating old ones |
@jfversluis if it would be that easy I would'nt bother you. I tried CLI ugrade-assistant and converted android, ios and the common xamarin project but did't get it working. Now I try the VS Ugrade Tool extension and the latest VS Preview version |
I've just tried the repo in the first comment (https://github.com/drasticactions/MauiMultiProject) and without changing anything I was able to run iOS, Android and Mac Catalyst. So you basically want to mimic whatever is in that project. For Windows there seems to be something not working unfortunately, probably because some configuration is missing or incomplete. I understand this issue is about documentation for it, I don't think that will come anytime soon. Single-project is our recommended and primary approach at this time. Maybe someone from the community might be able to help out here. |
@jfversluis interesting. I have no devices to choose from im visual studio for that (https://github.com/drasticactions/MauiMultiProject). |
Interesting. I was on Visual Studio for Mac and it worked without a problem there. On Windows I indeed see the same. Ironically enough, adding Then it complains about some resources it can't find in the |
SingleProject=True tells the compiler that the root things are shared and it needs to look at Platforms/Android The IDE not showing devices is a separate bug and should be logged with VS using the feedback tool. |
@jfversluis what is the error for windows? |
@davidbritch do we have docs for multiple projects? Do we need docs or does/should it just work? Is there any docs with the upgrade assistant maybe? |
This is what I meant by
Remove the references to those files or (probably) set the BuildAction for those files to AndroidResource |
@davidortinau I think this is more upgrade related, I think that was on your plate? |
@mattleibow It's hard to capture the details, but I think the key is somewhere here. It throws an NRE and if you look at the Stack Trace, it just calls the InitializeComponent and goes through XAML stuff, but there is a hint to a RadioButton there (there is no RadioButton in the app...) and some reference to ResolveThemeColor. My gut tells me there is some initialization somewhere that is missed. Full call stack: https://gist.github.com/jfversluis/ab3b01d7fb570ec0025a578e5969aa89 |
If someone interested, here is an original
|
@jfversluis You comment your own comment. Pretty awesome ;-) Ok, let's get more serious. I had success with the AndroidResources in a Multi-Project Solution. But it's not fully as you explained.
After some investigation I found @mattleibow reported an issue Not easy to add a "AndroidResource" to a maui project and Resource is ambiguous. So the trick is to fully qualify your Resource in the Android Project, because one is the MAUI Resource and one is the Android Platform Resource. So you end up with to different created |
+1UP |
Multi-Project is not available through the given link, can you please share it again. |
@Alvin-2101 |
@Alvin-2101 I added a Migration Guide here, maybe helpful. |
Thanks I will take a look. |
I also created a multi head maui app project and template some time ago https://github.com/mattleibow/MauiMultiHeadProject |
I'm experiencing the same issues. In Visual Studio no devices to select. When pressed Start i always get some Android simulator. Any solutions to this? |
So does this mean that Microsoft aren't supporting Multi-Project now? I can't find any up to date recommendations or un-recommendations. I'm looking at upgrading a pretty complex existing application, which I think would be better kept as multi-project. But I don't want to find that I've got problems later on. This is the flagship app for my client, and it would be disastrous to pick the wrong structure and have errors/problems as a result. |
I am keeping the multiple structure until the point I can and then I will be moving to a single project structure. |
Thanks -I think I need to take the plunge and go for the probably more complex migration and go straight to single project. |
We just tried to migrate to a large Xamarin.Forms app to a multi project solution, we ran into this problem of not being able to deploy. If Microsoft isn't going to support/fix the multi project solution then they should remove it from the migration guide and make it obvious that you have to go straight to a single project solution. |
Can you elaborate on what exactly is the problem/error that you are facing and for which platform? |
Same as the people above. There is no deploy option. The green play button just says "Start" the drop down doesn't have the options for android Emulators or Android Local Devices. If you do click on "Start" it fails on the deploy stage but with no info about why (not surprising since I couldn't select where to deploy to) This is the same as reported by people above, and the consensus seems that you have to use single project solution for it to work. There is no sample for multiple project solutions, there is no dotnet new support, there is no Visual studio new project option. And the Microsoft employee who made an example above (but couldn't get it working) deleted it because he was told to only focus on the single project solution. Our app supports Android and iOS but we have only migrated android so far. |
Hi @mattleibow, thank you for this template, it's helpful for our migration. But i have a question: how do we need to declare MAUI Handlers at such project structure? Thank you in advance |
I don't know if there is any recommended way from MS for this but this is how I register the handlers: I have public static MauiApp CreateMauiApp(MauiAppBuilder builder)
{
builder
.UseMauiApp<App>();
return builder.Build();
} Then in platform projects, in Do the same for protected override MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
// register your platform handlers to builder here
return MauiProgram.CreateMauiApp(builder);
} |
Adding an official template here: #20365 |
@mattleibow One new question - how to build and run only one platform in Muliti-Project structure? My case is - i have very limited space for Windows environment and I installed only MAUI & WinUI3 SDK. I don't need to install more SDKs cuz I'm going to test only Windows part, but VS is continiosly asking about Android, iOS and Mac SDK and plcks ability to build WinUI3 project only Issue is only happening on Windows at VisualcStudio, neither VS4Mac nor rider has this issue. Thank you for your answer in advance |
Description
In the MAUI GA blog entry, there is a section stating that MAUI supports being used in a "multi-project" (Multiple Projects with single target platforms, as opposed to a "Single-Project" which contains multiple target frameworks). However, I can't set it up. There's no template, nor samples in the MAUI repos for how to pull this off.
I've tried creating my own project (https://github.com/drasticactions/MauiMultiProject) to show this. While I was able to get Android to launch from a MAUI app based in a class project, I've been unable to get the others set up successfully. WinUI will throw an exception that
Application.Current
is null.I'm not sure how to set this up properly. Since we say this is a supported usecase, I think there should be documentation (either a sample or a template) with it setup. That will make it easier for anyone to integrate MAUI into a "single" application project.
Steps to Reproduce
Try and run https://github.com/drasticactions/MauiMultiProject on various platforms.
Version with bug
Release Candidate 3 (current)
Last version that worked well
Release Candidate 3 (current)
Affected platforms
iOS, Android, Windows, macOS
Affected platform versions
All
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: