dotnet / MobileBlazorBindings

Experimental Mobile Blazor Bindings - Build native and hybrid mobile apps with Blazor
MIT License
1.2k stars 151 forks source link

Bundle wwwroot into executable #332

Open IvanJosipovic opened 3 years ago

IvanJosipovic commented 3 years ago

Currently when publishing a Windows based Hybrid Blazor App, it will publish the executable and the wwwroot folder. Are there any plans to support embedding the wwwroot into the executable?

image

Eilon commented 3 years ago

Hi @IvanJosipovic the location of static files currently depends on the platform. They go into a different location depending on whether it's Windows, macOS, iOS, or Android, in part due to limitations of those platforms. Static files on disk tend to be the simplest approach because the files start out as static files on disk, so it's a bit easier to load them. With embedded resources we have to deal with differences in how filenames/folders are stored, so you end up needing additional manifest files and other complexities.

Long story short: It's definitely a nice idea, and something worth investigating in the future.

In the meantime if you could share info about why you're looking to change this, that would help guide the priority of this issue.

IvanJosipovic commented 3 years ago

Thanks for the response @Eilon. I see this suggestion being useful in the Windows/macOS targets only and primarily helping with aesthetics.

Benefits of embedding:

Eilon commented 3 years ago

Sure, these all seem reasonable. I think for many apps this would be largely solved by using an installer, for example an MSI, or going through an app store experience such as Windows Store or Apple App Store. Many apps will likely still be multi-file, but it might be nice to reduce some loose files.

dcuccia commented 3 years ago

I can second the single file use case - I am building portable no-install single file desktop apps and evaluating Blazor as the UI layer.

shaun-wilson commented 1 year ago

Has there been any progress on this request? It seems not as I have just been trying out Blazor Hybrid with WPF on .NET 8 RC1 and cannot find any combination of settings that bundles the wwwroot in the exe. Using dotnet publish along with the following settings in csproj gives a small exe (~2.5MB), but with the wwwroot folder/files beside it.

<PublishSingleFile>true</PublishSingleFile>
<SelfContained>false</SelfContained>
<IncludeNativeLibrariesForSelfExtract>true</IncludeNativeLibrariesForSelfExtract>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>

I just want to make a single exe that can be run without install or unpack - ie a portable program. In searching for a solution to this problem, I came across other users with the same desire;

  1. https://stackoverflow.com/questions/72433132/asp-net-core-blazor-hybrid-as-single-file-application
  2. https://old.reddit.com/r/Blazor/comments/m6z8dk/blazor_webassembly_hosted_is_it_possible_to_pack/