dotnet / aspire

An opinionated, cloud ready stack for building observable, production ready, distributed applications in .NET
https://learn.microsoft.com/dotnet/aspire
MIT License
3.65k stars 413 forks source link

`builder.AddProject<Projects.SampleMAUI>("app_maui"))`- or any other client project #876

Open moljac opened 10 months ago

moljac commented 10 months ago

Hi

I think from title should be clear what I am attempting to achieve.

Working on templates for MAUI repro samples and playing with Aspire. Being lazy bum (dev) I would like to use Aspire for service discovery for client apps (MAUI, console, desktop...).

Repro:

SampleAspireStarter.zip

CLI

 dotnet build ./SampleAspireStarter/SampleAspireStarter.AppHost/SampleAspireStarter.AppHost.csproj

Error I get is:

./SampleAspireStarter.AppHost/SampleAspireStarter.AppHost.csproj : error NU1201: Project SampleMAUI is not compatible with net8.0 (.NETCoreApp,Version=v8.0). Project SampleMAUI supports:
./SampleAspireStarter.AppHost/SampleAspireStarter.AppHost.csproj : error NU1201:   - net8.0-android34.0 (.NETCoreApp,Version=v8.0)
./SampleAspireStarter.AppHost/SampleAspireStarter.AppHost.csproj : error NU1201:   - net8.0-ios17.0 (.NETCoreApp,Version=v8.0)
./SampleAspireStarter.AppHost/SampleAspireStarter.AppHost.csproj : error NU1201:   - net8.0-maccatalyst17.0 (.NETCoreApp,Version=v8.0)

Seems like MauiAppBuilder should implement IDistributedApplicationBuilder

https://github.com/dotnet/aspire/blob/6464fea863ea9ba17712fb38301ec6558bb4810c/src/Aspire.Hosting/Extensions/ProjectResourceBuilderExtensions.cs#L24

MauiAppBuilder

https://github.com/dotnet/maui/blob/c5f3528e48055d3f75f98bf9037220132b56725e/src/Core/src/Hosting/MauiAppBuilder.cs

Am I on the right track?

Being able to add any client to Aspire would be really nice feature for not-only-web-distributed-app development.

davidfowl commented 10 months ago

This isn't supported as yet. Thanks for trying it though as it has come up in discussion. The focus so far has been on the server side only not clients.

moljac commented 10 months ago

This isn't supported as yet.

Any timeframe? No commitement. Just asking.

Thanks for trying it though as it has come up in discussion.

.NET@MS? I was guilty as charged for asking question.

The focus so far has been on the server side only not clients.

I created issue in Maui repo to and will discuss what needs to be done on Maui side. Thanks for the feedback.

davidfowl commented 7 months ago

@DamianEdwards any ideas where this should go?

DamianEdwards commented 7 months ago

We have a sample of this working with WPF and WinForms apps and the MAUI team is investigating what this could look like for MAUI apps. Adding references to MAUI projects from the AppHost project should be unblocked in preview 3 so the focus likely needs to shift to exploring guidance for integrating Microsoft.Extensions.Hosting and friends into MAUI projects in an idiomatic fashion.

@jamesmontemagno

jamesmontemagno commented 7 months ago

If there is a working sample at some point then yeah I would put in https://github.com/dotnet/aspire-samples/tree/main/samples

I think that we need to have guidance though for client app dev.

I believe there is work to do in .NET MAUI itself and most likely this ticket could be moved if that is the case?