Skip to content
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

Support for MAUI runtimes in ASP.NET Core? #35077

Open
Tracked by #2369
JustArchi opened this issue Aug 3, 2021 · 163 comments
Open
Tracked by #2369

Support for MAUI runtimes in ASP.NET Core? #35077

JustArchi opened this issue Aug 3, 2021 · 163 comments
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions enhancement This issue represents an ask for new feature or an enhancement to an existing one
Milestone

Comments

@JustArchi
Copy link

Hey,

I apologize in advance if this is not the correct place to ask this, but I didn't find any better one. Feel free to move this issue if appropriate.

For testing purposes, in MAUI net6.0-android project I've tried to reference other project of mine targetting net6.0 which is a library. I didn't have any issues doing so, but during compilation I've stumbled upon following error:

Error NETSDK1082 There is no Microsoft.AspNetCore.App runtime package available for the specified RuntimeIdentifier "android-x86"

If I understand this right, I can reference standard net6.0 projects because Microsoft.NETCore.App.Runtime.Mono.android-x86 exists and is usable, at least I successfully did that with example net6.0 library. However, I'd like to reference a library that has actual ASP.NET Core elements (Kestrel web server, API with MVC etc), which according to the error is impossible because it can't find a required android-x86 runtime, which seems to be correct as of today.

Now I apologize if I'm trying to do some extreme stupidity, or I don't understand something, but I wanted to verify whether it'd be possible to "convert" existing CLI project of mine which uses Kestrel and API controllers into an Android MAUI app that could start the "backend" part on the target machine, with some nice frontend utilizing those API endpoints over HTTP. I'm testing this in .NET 6.0 preview 6 if it matters.

Is this possible/planned? Or perhaps I'm doing something horribly wrong?

In any case, thank you in advance for answering, I appreciate it.

@JustArchi JustArchi changed the title Support for MAUI runtimes? Support for MAUI runtimes in ASP.NET Core? Aug 3, 2021
@Eilon Eilon transferred this issue from dotnet/aspnetcore Aug 3, 2021
@Eilon Eilon transferred this issue from dotnet/maui Aug 5, 2021
@Eilon
Copy link
Member

Eilon commented Aug 5, 2021

(Transferring back to aspnetcore repo...)

Hi @JustArchi , code that is specific to ASP.NET Core scenarios, such as hosting Kestrel, requires platform support, which as you discovered, it not available on some platforms, such as Android.

I think this might really be a question for the ASP.NET folks as to whether there is a desire to support certain features, such as Kestrel, on "arbitrary" platforms, or whether to specifically add support to particular platforms (e.g. android-x86).

Hosting a local web server in a cross-platform app is something reasonable (though perhaps not super common), so it's worth considering.

For right now I'm not aware of any plan to support this.

@Eilon
Copy link
Member

Eilon commented Aug 5, 2021

Tagging @danroth27 because I think you mentioned something about this the other day.

@JustArchi
Copy link
Author

JustArchi commented Aug 5, 2021

Thanks for your answer @Eilon, I appreciate it.

Hosting a local web server in a cross-platform app is something reasonable (though perhaps not super common), so it's worth considering.

Yeah I definitely don't see everybody jumping on this idea right away and bundling every Android/iOS/etc app with a local web server, but I also came to conclusion that it's something reasonable enough to at least suggest/evaluate on. I have no idea how much work would be required to bring ASP.NET Core runtime to those new .NET 6.0 platforms, but if it helps in any way then I'd be definitely interested in making use of such functionality, at least for that one use case I have in mind.

It could also be a decent alternative if somebody wanted to build an app that looks more like a typical website to you. To give you some idea, I have a CLI app realizing its functionality with bundled Kestrel web server and MVC APIs, which is not really any different from a typical ASP.NET Core website, but it's more of the CLI app and APIs are just an extra. Anyway, I bundle that app with frontend written in html/css/js (static files that Kestrel serves), which results in user navigating to his localhost app address, where he can control the app through a website interface (that calls appropriate API endpoints).

As an experiment I tried to convert this "idea" into Android app, where the app could create a very simple Webview with that localhost address (where the frontend is already mobile-aware), while launching the backend part the same as on all other OSes I build this for. This in result failed as of today, since there is no ASP.NET Core runtime for Android (which is just an example platform I tried to test it on).

I'm describing that just to give you some insight into what this whole "feature request" could be useful for, while MAUI is great on its own and building new apps is definitely going to be interesting, there might be more of such CLI apps with some kind of web interface that could easily be converted into Android apps without much hassle if just the ASP.NET Core runtime was available to make use of. It's not like my app requires something more than a web server with static files and MVC APIs anyway.

In any case thank you in advance for evaluation of this idea, perhaps it could be something to think of for the future.

@mkArtakMSFT mkArtakMSFT added the area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework label Aug 5, 2021
@mkArtakMSFT
Copy link
Member

@davidfowl feel free to update the label. This seems to be the closest match.

@juwens
Copy link

juwens commented Aug 30, 2021

@JustArchi to second your "reasonable scenario" statement.

We are actually started using local GRPC (client and server) in our current Xamarin app as an IPC technology to communicate between two apps.

We have some LOB-concerns which forces us to do a lot (and kinda complex) local IPC between our app and a third party app.

And to use one identical API technology on all Platforms targets (Android, iOS and Windows) we've chosen grpc.

@eestein
Copy link

eestein commented Oct 20, 2021

I've got the "same" problem.
I'm trying to add DI to my maui app using the idea James wrote here https://montemagno.com/add-asp-net-cores-dependency-injection-into-xamarin-apps-with-hostbuilder/
And then I get the error:

NETSDK1082 There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'iossimulator-x64'.
Sample.Mobile.Maui
C:\Program Files\dotnet\sdk\6.0.100-rc.2.21505.57\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targets 427

The same goes for maccatalyst-x64, android-x86 and linux-arm.

I created a mauilib with the default structure:

<Project Sdk="Microsoft.NET.Sdk">

	<PropertyGroup>
		<TargetFrameworks>net6.0-ios;net6.0-android;net6.0-maccatalyst</TargetFrameworks>
		<!-- <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net6.0-windows10.0.19041</TargetFrameworks> -->
		<TargetPlatformMinVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.17763.0</TargetPlatformMinVersion>
		<UseMaui>true</UseMaui>
		<SingleProject>true</SingleProject>

		<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-ios'">14.2</SupportedOSPlatformVersion>
		<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-maccatalyst'">14.0</SupportedOSPlatformVersion>
		<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-android'">21.0</SupportedOSPlatformVersion>
		<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.18362.0</SupportedOSPlatformVersion>
	</PropertyGroup>

	<ItemGroup>
	  <Folder Include="Platforms\iOS\" />
	  <Folder Include="Platforms\Windows\" />
	  <Folder Include="Resources\Fonts\" />
	  <Folder Include="Resources\Images\" />
	</ItemGroup>

</Project>

I tried recreating the projects twice from the command line, but it still won't work. dotnet new maui and dotnet new mauilib.

Is there a workaround for this? I'd very much like to be able to use DI, but I'm blocked as is.

Checking up the nuget repository, I found the references, but for .Mono. Is there something I'm doing incorrectly?
2021-10-20 at 10 40 51@2x

@danroth27
Copy link
Member

@eestein .NET MAUI already has support for dependency injection built-in. MauiAppBuilder exposes a Services property that you can use to configure your services. You shouldn't need to add any additional dependencies.

@eestein
Copy link

eestein commented Oct 20, 2021

@danroth27 thanks, I appreciate you taking the time to evaluate my question.
The thing is, I'm not adding anything extra.

This is the info for my maui lib.

These are my usings:

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Maui.Hosting;

These are the only nuget packages I've got installed:
image

These are the dependencies:
image

This is my csproj:

<Project Sdk="Microsoft.NET.Sdk">

	<PropertyGroup>
		<TargetFrameworks>net6.0;net6.0-ios;net6.0-android;net6.0-maccatalyst</TargetFrameworks>
		<Nullable>enable</Nullable>
		<UseMaui>true</UseMaui>
		<SingleProject>true</SingleProject>

		<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-ios'">14.2</SupportedOSPlatformVersion>
		<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-maccatalyst'">14.0</SupportedOSPlatformVersion>
		<SupportedOSPlatformVersion Condition="'$(TargetFramework)' == 'net6.0-android'">21.0</SupportedOSPlatformVersion>
		<SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.18362.0</SupportedOSPlatformVersion>
	</PropertyGroup>

	<ItemGroup>
		<ProjectReference Include="..\Sample.Data\Sample.Data.csproj" />
	</ItemGroup>

</Project>

And I still get the error:

/usr/local/share/dotnet/sdk/6.0.100-rc.2.21505.57/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(427,5): error NETSDK1082: There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'iossimulator-x64'. [/Users/eestein/Documents/dev/smp/sample-repo/Sample/Sample.Mobile.Maui/Sample.Mobile.Maui.csproj]

I'm not trying to waste anyone's time here, believe me when I tell you I research a lot before asking. The thing is I'm stuck on this one since yesterday. Before trying many things I found online I recreated the projects twice and they still won't work. I tried recreating from VS2022 and also from the command line on my macOS. I still get the error when I reference my mauilib from the maui app.

@davidfowl
Copy link
Member

Why did you include ASP.NET Core if you're only trying to use dependency injection?

@eestein
Copy link

eestein commented Oct 20, 2021

@davidfowl I didn't... I just created the maui lib using the provided template. And, I also tried removing that framework, I just couldn't find a way to do so.

I do need to use HttpClient, though

@Eilon
Copy link
Member

Eilon commented Oct 20, 2021

@eestein is that the CSPROJ of the project that's failing, /Users/eestein/Documents/dev/smp/sample-repo/Sample/Sample.Mobile.Maui/Sample.Mobile.Maui.csproj? Is there any other .targets or .props file or a global.json that might be affecting things?

@eestein
Copy link

eestein commented Oct 20, 2021

@Eilon let me take a closer look and I'll get back to you on that. Thanks.

I'm also looking for specific packages that could be adding the FW.

@davidfowl
Copy link
Member

Maybe it's the SampleData project reference?

@Eilon
Copy link
Member

Eilon commented Oct 20, 2021

A plain dotnet new mauilib should not reference AspNetCore in any way, so something else is bringing it in.

@eestein
Copy link

eestein commented Oct 20, 2021

Thank you, gentlemen!
@davidfowl your comment made me realize there was one specific thing I hadn't tracked. The problem was that one of the libs had a reference to FluentValidations.AspNetCore instead of FluentValidations. That's what was loading the aspnetcore FW.

I'm sorry to have wasted your time. But I also think, if possible, a better error message could be provided. If in the message we could see the offending library, that would help a lot!

Thank you all, @danroth27 , @Eilon and @davidfowl

Please consider my suggestion for the error message.

@juwens
Copy link

juwens commented Nov 6, 2021

Come on guys and gals, GRPC is THE strongly advertised tech from MS for IPC and SOA.
You really need to bring asp.net to Net 6 (Xamarin) iOS and Android Runtimes.

In the end, that was the promise MS made, one runtime for all Platforms, not: your lib might only run on one or two Net 6 runtimes (bot not on ios or android or uwp).

Today we can still use the "Grpc.Core" Server wich works without asp.net, but this will be deprecated in the near future.

rpc-dotnet (the Grpc.Net.Client and Grpc.AspNetCore.Server nuget packages) is now the recommended gRPC 
implementation for .NET/C#. The original gRPC C# implementation (the Grpc.Core nuget package)

https://grpc.io/blog/grpc-csharp-future/

@ramondeklein
Copy link

I am quite confused why this is still not supported. I already use the Kestrel webservice in my Xamarin app for a while. It seems that Microsoft.AspNetCore (v2.2.0) works fine in Xamarin and probably will work in MAUI too. Later versions don't work anymore, because they are not available as separate packages. I never understood why an application that exposes a web-service should be treated so special (I don't know of any other language that does this). ASP.NET core was just a bunch of packages with .NET core v2.2 and it worked fine.

I tested it with iOS, Android and UWP applications without any issues. I was hoping that MAUI and .NET 6 would really bring us one .NET.

@danroth27
Copy link
Member

Hi folks. I'd like to collect some more details on the specific scenarios for using ASP.NET Core in a mobile app. So far from the feedback in this issue I've identified two scenarios:

Anything else?

@juwens
Copy link

juwens commented Dec 13, 2021

@danroth27 thanks for taking a look into this.

Additional to #35077 there is local network GRPC planned.
For example:

  • GRPC call from a smartwatch to mobile-phone
  • GRPC call from a pc to a mobile phone

tl/dr:

  • case "smartwatch -> mobile" : ad-hoc controlling the app temporarily, when you need your hands and cannot hold the mobile phone at the moment; afterwards continuing on the phone
  • case "pc -> mobile phone": use the convenience of a keyboard and big screen to enter data and review the result of the data collected with the mobile phone

It all boils down to one person continuously switching between 3 devices (mobile phone, pc, smartwatch) to do its work.
Functionality/state which is held on one "main" device (usually mobile phone), and depending the circumstances is controlled by phone itself, smartwatch, pc.

Usually you would do that with a central server/could service holding the state/functionality.
For privacy and ease of configuration reasons, we are bound to the solution of no-server/cloud solution, where the "main" device holds the state.

@nextfool
Copy link

Hi folks. I'd like to collect some more details on the specific scenarios for using ASP.NET Core in a mobile app. So far from the feedback in this issue I've identified two scenarios:

Anything else?

This absolutely wonderful, thinking about a fully functioning backend web server (restful api, gRPC, signalR, database etc.) working with WebView, this gonna change the way people build mobile apps!!!

Really looking forward to this.

@dougbu
Copy link
Member

dougbu commented Jan 31, 2022

Putting this on the @dotnet/aspnet-blazor-eng radar. This is not really a general area-infrastructure issue.

@ramondeklein
Copy link

@dougbu I’m not sure why this is marked a Blazor issue. It has nothing to do with Blazor. When you read my comment from December 7, then I try to explain that it is a fundamental .NET issue, because Kestrel isn’t an ordinary package anymore, but considered a “platform”. It”s not a real MAUI issue, but a fundamental ASP.NET issue.

We implemented a Kestrel based webserver (using ancient Kestrel package from the .NET Core 2.2 era) and have an Angular client on top of it. It works great, but not being able to upgrade Kestrel is not a sustainable solution.

@javiercn javiercn added area-runtime and removed area-infrastructure Includes: MSBuild projects/targets, build scripts, CI, Installers and shared framework labels Feb 1, 2022
@MartyIX
Copy link

MartyIX commented Jun 20, 2023

@kamranattari4192 , is compiling a custom Kestrel an option? If so, does this comment help: #35077 (comment)

A friend did some experiments. Apparently it’s sufficient, to add mobile TFMs (net7.0-android, etc.) to the targetframeworks, and disable “quic”

for example here:

@juwens Maybe you can create a PR and it would move the needle a bit here.

@Falco20019
Copy link

Hey @JamesNK, any updates your evaluations?

@ramondeklein
Copy link

We were still using the old Kestrel (from .NET 2.2) in our Xamarin applications, but there is another issue that needs to be solved to allow proper use of Kestrel in Xamarin/MAUI. When iOS applications are suspended, then the OS may also close the TCP socket. When the application resumes, then the old Kestrel doesn't open a new socket and the web-server is effectively dead. Even if you are able to integrate the latest Kestrel in Xamarin/MAUI, then this issue also needs to be addressed.

I reverted back to using HttpListener, although it has one major flaw. It doesn't support cancellation, so I had to solve it in a rather clumsy way. But I am able to suspend and resume it properly by stopping/starting the listener during sleep/resume events.

@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Aug 24, 2023
@safetonet-github
Copy link

safetonet-github commented Oct 28, 2023

Hi folks. I'd like to collect some more details on the specific scenarios for using ASP.NET Core in a mobile app. So far from the feedback in this issue I've identified two scenarios:

Anything else?

@danroth27 Local proxy server. Infosec/deep content inspection/analysis etc. MsQuic supports being built for iOS, but no "official" builds are being done. Not to be critical, but Microsoft needs to decide if it really is cross-platform or if it's only pretend cross-platform. No other modern framework has this problem.

Sorry to sound critical or rantish but I pushed at my company and with partners to go with .NET stack and I'm going to look foolish, again.

@safetonet-github
Copy link

safetonet-github commented Oct 29, 2023

Just an update here. I went and pulled ASP.NET in its entirety yesterday, deleted HTTP/3, deleted IIS and HttpSys integration, the appref consolidation system and built all the packages that used to exist at 2.2.*. It took about 10 hours having never worked on any core .NET code before. Now I can use all the ASP.NET stuff I wanted on MAUI because I deleted links to Microsofts proprietary systems and MsQUIC, which, although is a great OSS, MS refuses to officially support all platforms and the C# wrapper in System.Net.Quic is massively out of sync with the MsQUIC development cycle.

@softworkz
Copy link
Contributor

@safetonet-github - Sounds interesting! Do you have a fork with those changes?

@safetonet-github
Copy link

safetonet-github commented Oct 29, 2023

@softworkz https://www.nuget.org/packages?q=jokersoft

I changed the package names only. The project does generate some namespaces but AFAIK, they're all internal. In other words, there are some cases where code is in Jokersoft.* NS, but should only be internal. Therefore, should be a drop-in replacement with original MS namespaces preserved. You will therefore get conflicts if you import both the Jokersoft.* package and matching real Microsoft.* package.

Some caveats:

  • Not every single package was published. There will be some missing. There are 90 published by my count. Razor, MVC etc dropped IIRC.
  • No guarantees that they all work. I have no time to test 90 packages on every platform.
  • I deleted / excluded the authorization packages and there is strong coupling in Kestrel and SignalR to them. I placed throw NotImplementedException in some of function calls that are coupled, and outright deleted the authorization middleware integration in kestrel core. So, you'd need to bring in your own auth middleware and make sure it takes priority over other middlware.

I can live with these shortcomings cause I just need a high performance HTTP server for proxying. It's probably the best that can be done while we wait to see what Microsoft will do to sort out their cross-platform plan.

I'll see if I can publish the changes somewhere but I rammed through this in 1 day, it's gonna be a mess and the only benefit to publishing it will be for people to repro packages on their own.

@safetonet-github
Copy link

@softworkz For transparency only, https://github.com/safetonet-github/AspNetCore

@softworkz
Copy link
Contributor

Thanks a lot for publishing! We're in the same boat, as we just need a really small piece of the cake (i.e. a decent http and websocket server) in this case. And that part would easily run on MAUI platforms.

I was asking for your results, to see how dirty it would be to do so with recent versions (done it before with netcore3).
As far as I'm seeing it: the problem is not to do it once, but it's really a problem to do this continuously, following all minor and major updates...

That's why an official way (like a smaller subset which also runs on MAUI) would really be great!

@safetonet-github
Copy link

safetonet-github commented Oct 30, 2023

@softworkz It's probably scriptable to some degree, especially if you don't change the package names and just use your own private nuget. Basically you just need a script that will edit the csproj files and set <GeneratePackageOnBuild>true</GeneratePackageOnBuild> and <IsPackable>true</IsPackable and then run normal build.

The problem is, excluding IIS, HttpSys and HTTP/3. For IIS and HttpSys, you could script removing references to these projects and excluding them from build. For removing HTTP/3, you'd probably need to maintain a patch you apply that removes the HTTP/3 code. It's not extensive.

I realize of course an official fix would be good but ya know.

@John0King
Copy link
Contributor

@softworkz @JamesNK @danroth27 @Eilon
image

this is what I do for the server lib

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <!--<OutputType>Exe</OutputType>-->
  </PropertyGroup>

  <ItemGroup>
    <Reference Include="C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\8.0.0\*.dll" Exclude="C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\8.0.0\aspnetcorev2_inprocess.dll">
      <Private>False</Private>
      <CopyToOutputDirectory>Never</CopyToOutputDirectory>
    </Reference>
  </ItemGroup>

</Project>

and the maui project

<!-- I had to copy the dll  in the maui project  -->
<ItemGroup>
  <ProjectReference Include="..\InternalServer\InternalServer.csproj" />
  <Reference Include="C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\8.0.0\*.dll" Exclude="C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\8.0.0\aspnetcorev2_inprocess.dll">
  </Reference>
</ItemGroup>

and a special edit of program.main

// in server "library"
public class Program
{
    public static void Main(string[] args)
    {
        
        var app = CreateWebApp(args);

        //app.Start();
        app.Run();
    }

    public static WebApplication CreateWebApp(string[] args)
    {
        var builder = WebApplication.CreateBuilder(new WebApplicationOptions
        {
            ApplicationName = nameof(InternalServer),
            Args = args,
            ContentRootPath = AppContext.BaseDirectory,
            EnvironmentName= "Production"
        }) ;
        //builder.WebHost.UseKestrel();


        builder.Services.AddAuthentication();
        builder.Services.AddAuthorization();

        var app = builder.Build();

        // Configure the HTTP request pipeline.
        if (!app.Environment.IsDevelopment())
        {
            app.UseExceptionHandler("/Error");
        }
        app.UseStaticFiles();

        app.UseRouting();

        app.UseAuthorization();

        app.UseWelcomePage();

        return app;
    }
}


// and in maui android app's  MainApplication.cs

[Application(UsesCleartextTraffic = true)]
public class MainApplication : MauiApplication
{
    public MainApplication(IntPtr handle, JniHandleOwnership ownership)
        : base(handle, ownership)
    {
    }

    protected override MauiApp CreateMauiApp()
    {
        var serverApp = InternalServer.Program.CreateWebApp(new[] { "--urls", "http://127.0.0.1:5000" });
        serverApp.Start();
        return MauiProgram.CreateMauiApp();
    }
}

Conclusion

it seems it's the Microsoft.AspNetCore.App meta package prevent u you use asp.net core , not the android platform

@Eilon
Copy link
Member

Eilon commented Nov 16, 2023

@John0King right, the problem is that if your app runs on Android and uses anything for which there is a required ASP.NET Core native runtime implementation, then it will crash the app, because there's no such thing on Android. Many things will work because it's C#/.NET managed code, which runs fine. But there are features that require native implementations for each platform, and there's no ASP.NET Core native implementation on Android.

@softworkz
Copy link
Contributor

@John0King - Thanks for your findings. That's significantly better than recompiling after ripping out unneeded stuff.

@Eilon

I'm not sure how much you followed this conversation, but almost all of us here are looking for something very limited, in most cases it's nothing more than having a replacement for the age-old and buggy HttpListenerHost implementation which came from Novell and made its way into Mono and from there even into dotnet (embarrassingly..)

What's needed (for most) is a fraction of Asp.NET. Maybe the title should rather be something like "Provide a stripped-down subset of Asp.NET core for mobile app targets.

As discussed earlier, there's no need for doing any native implementation for those parts were there isn't one yet. Many of us have posted here about their needs and their workarounds they did to get Asp.NET working on those platform.
There wasn't a single one who has reported an issue about missing functionality and NotImplementedExceptions.

It's good as it is - the one and only thing that's needed is to fence out a subset and provide a package for that, that's all.

@xljiulang
Copy link

/usr/share/dotnet/sdk/8.0.100/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.FrameworkReferenceResolution.targets(491,5): error NETSDK1082: There was no runtime pack for Microsoft.AspNetCore.App available for the specified RuntimeIdentifier 'linux-bionic-arm64'.

@BretJohnson
Copy link
Member

Would using https://github.com/microsoft/vs-streamjsonrpc meet the needs here, for many of the use cases like those described by @softworkz here #35077 (comment)? It seems like a good match and is in fact what I'm using currently for MAUI app to desktop RPC connectivity (over a socket connection). VS / VS Code brokered services also use JSON RPC heavily with this library. It works well. If there's a need for a web server, to serve up web pages, ASP.NET seems like a good match. But when the need is doing bidirectional RPC-style communication between a MAUI app and anything else, using JSON RPC seems like a better tool for the job.

@softworkz
Copy link
Contributor

softworkz commented Feb 2, 2024

Would using strmprcjsn meet the needs here, for many of the use cases like those described by @softworkz here #35077 (comment)? It

In the comment you referenced, I wrote:

in most cases it's nothing more than having a replacement for the age-old and buggy HttpListenerHost implementation

and futher above:

as we just need a really small piece of the cake (i.e. a decent http and websocket server)

So I'm afraid, but "strmprcjsn" is far away from any of the use cases I have described.

If there's a need for a web server, to serve up web pages, ASP.NET seems like a good match.

Which is the actual (and only) subject of this conversation.

@BretJohnson
Copy link
Member

@softworkz Thanks. I think I just misunderstood your use cases. Here's another summary comment #35077 (comment), identifying two main types of use cases:

For the second use case (IPC) doing JSON-RPC, via streamjsonrpc or another library, is arguably a good choice, as is gRPC. No web server required.

For the first use case (building a mobile app as a web app), you of course need some kind of web server, ASP.NET being a candidate. Though for that use case, it's not (yet) clear to me why most folks wouldn't want to use MAUI Blazor Hybrid for this, as it's kind of made for that. I expect there are some good reasons, but I haven't read the full thread to understand them yet.

@softworkz
Copy link
Contributor

softworkz commented Feb 2, 2024

Though for that use case, it's not (yet) clear to me why most folks wouldn't want to use MAUI Blazor Hybrid for this, as it's kind of made for that.

Maybe because some already have a mature application architecture running on a wide range of platforms and are looking for appropriate middleware which allows them to run their software on MAUI in a webview with little changes (and without redeveloping).
Or maybe, because Blazor/Hybrid doesn't allow to cover all use cases or is too specific and inflexible for your requirements.
Or maybe, becasue the primary purpose of the http server is not actually to drive an app's UI and you are not just serving to localhost but to the local network or even beyond.

Reading through the whole thread reveals, that the ones you quoted are not "the two main use cases". There are many different ones actually, and when you need a webserver, then you need a webserver and not Blazor hybrid and surely not streamrpc or something. There are plenty of ways to do network communication in some form and I think everybody how came here knows that and would have already chosen an alternative way when the requirement wouldn't be specifically about having an http server.

@BretJohnson
Copy link
Member

@softworkz Thanks. I better understand where you're coming from now.

@JamesNK
Copy link
Member

JamesNK commented Feb 2, 2024

@BretJohnson Dan Roth asked for scenarios where this feature would be useful. I recommend looking at its replies as a good starting place: #35077 (comment)

@BretJohnson
Copy link
Member

Thanks. I read thru all of the replies (there are so many!). Now I see that while streamjsonrpc (which doesn't require ASP.NET) may be a good choice for greenfield RPC needs, ASP.NET is so darn useful and widely used, including for support of gRPC, that there are lots of reasons to support it (or at least the most used subset of it) being embedded in MAUI apps.

@softworkz
Copy link
Contributor

Bret - somehow I get the impression that you are on an advertising mission, trying to place as many sentences as possible containing strmprcjsn...

@BretJohnson
Copy link
Member

That wasn't really my intention. We've been using it a lot for the Microsoft stuff I work on, including mobile, for IPC, and I rather like it, but folks should use whatever works best for them. If gRPC is a better choice, use it (though I guess it currently has the ASP.NET dependency). Or use something else. I'm on a MAUI tooling team at Microsoft btw - not MAUI itself, but kind of MAUI adjacent. Mostly I wanted to understand well customer needs here, for both IPC and non-IPC scenarios, to help us meet them. And I think I have a pretty good sense of that now.

@danroth27 danroth27 added the enhancement This issue represents an ask for new feature or an enhancement to an existing one label Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions enhancement This issue represents an ask for new feature or an enhancement to an existing one
Projects
None yet
Development

No branches or pull requests