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

Epic: Blazor developers can target and deploy their applications to desktop platforms, allowing them to run natively #2536

Closed
5 of 7 tasks
maddymontaquila opened this issue Oct 26, 2020 · 84 comments
Assignees
Labels
area/blazor 🕸️ Blazor Hybrid / Desktop, BlazorWebView
Projects

Comments

@maddymontaquila
Copy link
Member

maddymontaquila commented Oct 26, 2020

Summary

In .NET 6 we want to extend Blazor's target scenarios to include native desktop applications via web-based rendering.

Note: This is a proposed experience for .NET 6 and not yet committed.

User Stories

User Stories under this Epic:

@RChrisCoble
Copy link

Are other platforms in play here as well? Like MBB's usage of iOS and Android to complete this story? Or maybe the inclusion of MBB into ASP.Net brings those and this epic fills the gap?

@Eilon
Copy link
Member

Eilon commented Oct 26, 2020

I'm in the loop, One .NET!

@RChrisCoble
Copy link

@Eilon !!! I for one welcome our One .Net overlords.

For me, there's one big piece which brings Blazor together in a powerhouse .Net 6 release, but it's over on the Runtime team. @danroth27 can you throw your weight around to get this slotted between now and November?

.NET WebAssembly support of task based parallelism. #40619

@wakuflair
Copy link

Is it something with MAUI?

@msftbot
Copy link

msftbot bot commented Oct 28, 2020

Thanks for contacting us.
We're moving this issue to the Next sprint planning milestone for future evaluation / consideration. We will evaluate the request when we are planning the work for the next milestone. To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@kristof12345
Copy link

Hi!
Any update on this? Can we expect this feature in .NET 6?
Thank you.

@Eilon
Copy link
Member

Eilon commented Jan 29, 2021

Hi @kristof12345 yes this is part of the plans for .NET 6!

@Pilchie
Copy link
Member

Pilchie commented Jan 29, 2021

👀

@mrlife
Copy link

mrlife commented Feb 17, 2021

With MAUI introducing support for the Android and iOS platforms, and since Blazor is built on top of MAUI, will Blazor support those platforms as well?

@Eilon
Copy link
Member

Eilon commented Feb 17, 2021

@mrlife the main goal for .NET 6 is to support the Windows and macOS desktop platforms, but we will surely have code running on Android and iOS as well, but it might not be fully supported at that time.

@LeonarddeR
Copy link

I hope that accessibility for impaired people (like blindness) will be accounted for so apps like these will be accessible from the start, or at least the examples will be.

@kmanev073
Copy link

Is this available in the .NET 6 Preview 1? Thanks in advance.

@todosrc
Copy link

todosrc commented Feb 22, 2021

I want Blazor Desktop to also support automatically update themselves. like electron-updater.

Idea :

ElectronNET/Electron.NET#259
https://github.com/ElectronNET/Electron.NET/blob/master/ElectronNET.API/AutoUpdater.cs

https://github.com/NetSparkleUpdater/NetSparkle
https://github.com/Squirrel

cheers>>

@Eilon
Copy link
Member

Eilon commented Feb 22, 2021

@LeonarddeR accessibility is certainly important for all apps so I'm adding that to the checklist of things to look into.

@Eilon
Copy link
Member

Eilon commented Feb 22, 2021

@kmanev073 said:

Is this available in the .NET 6 Preview 1? Thanks in advance.

It is not in Preview 1. We plan to have this in no later than Preview 4.

@Eilon
Copy link
Member

Eilon commented Feb 22, 2021

@todosrc said:

I want Blazor Desktop to also support automatically update themselves. like electron-updater.

Installation/deployment/update support is an interesting problem, and we are looking at various solutions to this, including using some of the ones you mention!

@birbilis
Copy link

Remember ClickOnce deployment?

@robertmclaws
Copy link

So, something to consider while you folks are looking into this.

I'm building BurnRate.io, and we're in the process of moving a large OData/TypeScript/Webpack app to Blazor. When we add support for installing the app to the Desktop, we're still planning on shipping our Blazor WebAssembly version to the web, so people can access it where- and however they want. Up to this point, we had planned on doing that through Electron.NET.

However, Electron's update infrastructure is less than awesome, and requires a lot to build multiplatform update binaries. This should be wholly unnecessary with Blazor.

It would be great if the Blazor Desktop version could just download a manifest of MD5 hashes for the app files, and if any of them differ from what is installed, the app downloads them from the server-deployed version. That way, it's seamless for everyone, I know my customers will always be running the latest version, and you don't have to worry about trying to package MSI files or anything like that.

If security is an issue, then the files could all be digitally signed on the server, to reduce the risk of tampering.

I hope that real-world situation helps with your planning. We are a Microsoft for Startups / Microsoft Partner company, so if you have a TAP that would let us test this before the preview, would love to participate. Thanks so much!

@Webreaper
Copy link

This would be totally awesome. My app (http://github.com/webreaper/damselfly) bundles the installers/zip for the desktop electron wrapper into the Docker images, and I've used some javascript interop between Electron and the server to determine if the current container matches the server that's providing its content. If not, the user is notified and can optionally download the DMG/zip/AppImage file from the server and upgrade. I'll probably implement one-click download/install at some point in the future. But it would be great if Blazor could provide all the scaffolding to do this automatically without me having to write the versioning management and server/desktop JS interop by hand.

@rogihee
Copy link
Contributor

rogihee commented Mar 1, 2021

I think if Blazor Desktop is built on top of MAUI with WinUI3 which requires Win10 1809, then MSIX might be a good option as well.

@JohnGalt1717
Copy link

@rogihee My perfect world is somewhere very close to that too. I'd like to see WinUI 3 across all of MAUI including Web and all other platforms and that Blazor Desktop would just be a markup syntax for MAUI...

@Color-Dark
Copy link

Color-Dark commented Mar 1, 2021

@mrlife the main goal for .NET 6 is to support the Windows and macOS desktop platforms, but we will surely have code running on Android and iOS as well, but it might not be fully supported at that time.

So, would it not support Linux desktop platform?

@shashank-shekhar
Copy link

@kmanev073 said:

Is this available in the .NET 6 Preview 1? Thanks in advance.

It is not in Preview 1. We plan to have this in no later than Preview 4.

@Eilon is there a planned cadence for the preview releases?

@Eilon
Copy link
Member

Eilon commented Mar 2, 2021

@shashank-shekhar - This is all part of .NET 6, so when the code is ready it will be in the next .NET 6 preview. We're hoping to get something into .NET 6 Preview 3, but no later than .NET 6 Preview 4.

@Eilon
Copy link
Member

Eilon commented Mar 2, 2021

@lucifer-morning-star said:

So, would it not support Linux desktop loatforms?

Linux is not currently planned, but with .NET MAUI (much like Xamarin.Forms) it's conceivable that it could be added in the future.

@tub5
Copy link

tub5 commented Mar 3, 2021

@Eilon said:

Linux is not currently planned, but with .NET MAUI (much like Xamarin.Forms) it's conceivable that it could be added in the future.

Damn, that's a deal breaker for us. Looks like we'll have to stick with Electron.NET for the foreseeable.

@Kryptos-FR
Copy link

@tub5 have a look at Avalonia UI or Uno.

@tub5
Copy link

tub5 commented Mar 3, 2021

@Kryptos-FR we looked at both previously but decided using Blazor with Electron.NET would suffice until the Blazor Desktop Applications came about. As our application is written using Blazor, when the ability is implemented, the migration should take a matter of days rather than weeks/months recreating the UI.

@Color-Dark
Copy link

Color-Dark commented Mar 3, 2021

@lucifer-morning-star said:

So, would it not support Linux desktop platform?

Linux is not currently planned, but with .NET MAUI (much like Xamarin.Forms) it's conceivable that it could be added in the future.

So,

@lucifer-morning-star said:

So, would it not support Linux desktop patform?

Linux is not currently planned, but with .NET MAUI (much like Xamarin.Forms) it's conceivable that it could be added in the future.
So, Is it possible give a way to make the Blazor applications to desktop platforms just like SteveSanderson's attempt (https://github.com/SteveSandersonMS/WebWindow) . ,or make this lib have a official support in .NET 6 ?It may be a easy way to support Linux desktop platforms in a short time.

@RChrisCoble
Copy link

I believe Linux was only descoped from .Net 6 during their planning. I would imagine we'll see that re-scoped for .Net 7.

You can see on this page the Feature still mentions Linux, but they removed it from the actual feature once you click on it.

@ivanjx
Copy link

ivanjx commented Jun 22, 2021

is there any guide on how to access the content inside wwwroot folder? i tried to use httpclient but it gives me empty base uri error. tried to set the base to 0.0.0.0 but it says the address is not a routable address. thanks.

@nvmkpk
Copy link

nvmkpk commented Jun 22, 2021

is there any guide on how to access the content inside wwwroot folder? i tried to use httpclient but it gives me empty base uri error. tried to set the base to 0.0.0.0 but it says the address is not a routable address. thanks.

I think you would need to use regular System.IO.File to read the files.

@Eilon
Copy link
Member

Eilon commented Jun 22, 2021

@realivanjx it depends on where you're trying to read it from. If you're just trying to use it within the web view (e.g. for CSS, images, etc.) you can reference it directly from HTML content, for example, <img src="content/flower.jpg" />. If it's from elsewhere in the app, it depends on what you're trying to do, but you usually wouldn't read files from the wwwroot folder from elsewhere in the app.

@Xyncgas
Copy link

Xyncgas commented Jun 23, 2021

@realivanjx If you are hosting your web on a server, you can always access it with relative or absolute (https://(your server's domain)/(your file)) url, within the app, adding '/' first means you are navigating from the root

@ivanjx
Copy link

ivanjx commented Jun 23, 2021

yes it works if i use it directly on the html or razor components such as img etc. what im looking at is like the weather forecast example but running it with blazor desktop. something like this in the default project template's FetchData.razor:

@code {
    private WeatherForecast[] forecasts;

    protected override async Task OnInitializedAsync()
    {
        forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");
    }

    public class WeatherForecast
    {
        public DateTime Date { get; set; }

        public int TemperatureC { get; set; }

        public string Summary { get; set; }

        public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
    }
}

@Eilon
Copy link
Member

Eilon commented Jun 23, 2021

@realivanjx in that case I would read the file directly. In Preview 5 it's a bit awkward to read it directly and that's something we aim to fix in an upcoming milestone using a feature called MauiAssets. You'll be able to use a simple API to read these files directly without trying to use HTTP (which doesn't really make sense in a desktop app).

Another thing to keep in mind is to make this more platform-independent (such as Blazor Desktop and also Blazor WebAssembly and Blazor Server), you might want to introduce a custom service in the Dependency Injection (DI) container, such as IForecastLoader, for which you have a different implementation on each platform. In Blazor Desktop it could use MauiAssets, on Blazor WebAssembly it could use HttpClient, and on Blazor Server maybe HttpClient or something else.

@Webreaper
Copy link

For Blazor server, presumably, the best option would be to use UseStaticFiles? I use this in my project and it works very well.

        app.UseStaticFiles(new StaticFileOptions
        {
            FileProvider = new PhysicalFileProvider("/path/to/my/files"),
            RequestPath = "/forecasts"
        });

You'd then call something like

       forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("/forecasts/weather.json");

I haven't tried Maui or Blazor desktop yet, so can't comment on that side of things.

@shashank-shekhar
Copy link

I don't see this in VS 2020 17.0.0 Preview 2 - has this feature not been shipped yet or am I missing something ?

@danroth27
Copy link
Member

Hi @shashank-shekhar. This work is happening as part of .NET 6. The .NET MAUI Blazor app templates don't show up in VS2022 yet, but they will in an upcoming VS2022 preview update.

@ivanjx
Copy link

ivanjx commented Aug 5, 2021

is there any way to hide or package the wwwroot files inside the app's exe or app data folder so the end user wont easily modify those files? thanks.

@Eilon
Copy link
Member

Eilon commented Aug 5, 2021

@realivanjx that's not something that we have planned in the initial release.

@Webreaper
Copy link

Presumably if this was really important, you could embed the files in blob or (encrypted) zip file, and then use a controller as a facade in front of those files, which would extract the files on-demand as required at runtime. Messy, but would probably work?

@Eilon
Copy link
Member

Eilon commented Aug 5, 2021

The question that comes up when people ask about embedding files is: what are you trying to protect? Ultimately there's a WebView in there that people can "sniff" into in various ways. There should be no genuine security concerns because there is no trust at that level. Users can't modify application files if they're not admins, and if they are admins, or it's locally installed, they can see/modify whatever they want and you can't prevent that no matter how hard you try. I think some developers want to prevent users from casually seeing or modifying app files (that is, without much effort). My personal view is that that's somewhat pointless because why bother, but certainly others have a different view on that.

We might at some point offer ways to make it easier to embed the files, but to be clear, it offers no additional security in a trust boundary. It only adds obscurity/obfuscation.

@ivanjx
Copy link

ivanjx commented Aug 5, 2021

in my case i dont really seek security that much. this is just matter of tidiness since the app is portable one. for now i managed to make everything into single exe file but the wwwroot folder.

@tub5
Copy link

tub5 commented Aug 5, 2021

@realivanjx can't you wrap it in an installer?

@IvanJosipovic
Copy link

I have also requested this feature in the MBB repo, dotnet/MobileBlazorBindings#332
I think this is a highly valuable feature and conforms to how other frameworks like Electron work.

I prefer not to use installers as they are complicated and not needed for single file executables. Many modern projects simply ship a single exe per platform.

@Webreaper
Copy link

It sounds like what you're referring to is a properly compiled single-file executable for .Net apps, which doesn't self-extract to a temp location at startup but is actually a single compiled binary - ideally with the wwwroot etc type non-binary files embedded as some sort of resource. My understanding is that there's a separate issue in the .Net runtime to try and achieve this (I've got it bookmarked somewhere but can't find the link...).

@nvmkpk
Copy link

nvmkpk commented Aug 6, 2021

The current implementation does not let us configure the file provider it uses. I filed the issue #1349 but there hasn't been much activity on it so far.

@mvelbaum
Copy link

mvelbaum commented Sep 4, 2021

@Eilon what's the status of Linux desktop support for Blazor hybrid apps? I understand that MAUI is used to some extent, and MAUI does not support Linux.

@realZhangChi
Copy link

@Eilon what's the status of Linux desktop support for Blazor hybrid apps? I understand that MAUI is used to some extent, and MAUI does not support Linux.

I found a related repository: https://github.com/jsuarezruiz/maui-linux

@Eilon
Copy link
Member

Eilon commented Sep 7, 2021

Linux support is not in the plans for the current release, but it's certainly something we're thinking about. There have been a few issues logged on this before: https://github.com/dotnet/maui/issues?q=label%3A%22platform%2Flinux+%F0%9F%90%A7%22+

@Eilon
Copy link
Member

Eilon commented Dec 7, 2021

Closing this because most of this works by now, and everything else should be tracked with various bugs marked as area/blazor: https://github.com/dotnet/maui/issues?q=is%3Aopen+is%3Aissue+label%3A%22area%2Fblazor+%F0%9F%95%B8%EF%B8%8F%22

@Eilon Eilon closed this as completed Dec 7, 2021
.NET 6.0 automation moved this from Committed to Completed Dec 7, 2021
@msftbot msftbot bot locked as resolved and limited conversation to collaborators Feb 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/blazor 🕸️ Blazor Hybrid / Desktop, BlazorWebView
Projects
.NET 6.0
  
Completed
Development

No branches or pull requests