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

BlazorWebView needs to support Razor Class Libraries with Static Web Assets #129

Closed
jspuij opened this issue Jul 13, 2020 · 9 comments
Closed
Labels
area-mobileblazorbindings Experimental Mobile Bindings for Blazor hybrid-apps Issues related to hybrid or web/HTML apps
Milestone

Comments

@jspuij
Copy link
Contributor

jspuij commented Jul 13, 2020

No description provided.

@Eilon
Copy link
Member

Eilon commented Jul 20, 2020

Ideas:

Support for Razor Class Libraries (RCLs) means that you can build your UI once and then consume it from a Blazor Server app, Blazor WASM app, Mobile Blazor Bindings Hybrid App, etc. There might be some restrictions, but most things should just work.

@Eilon Eilon added this to the 0.5-preview milestone Jul 20, 2020
@Eilon Eilon added the area-mobileblazorbindings Experimental Mobile Bindings for Blazor label Jul 20, 2020
@Eilon
Copy link
Member

Eilon commented Jul 24, 2020

Also need to demonstrate how to use DI so that when the RCL is hosted on different platforms (e.g. web, iOS, Android), each can provide its own platform-optimized implementation of that service. For example, geolocation APIs can be done differently on browser vs. using Xamarin.Essentials on devices.

@arivera12
Copy link

arivera12 commented Oct 2, 2020

How this gonna be manage? Since we have all blazor RCLs on a base project blazor wasm and server needs the wwwroot/index.html as their entry point. I tried working around with a default blazor project and adding reference from the base class I got it up and running but for some reason it doesn't see the pages folder RCLs, I mean index, counter and weather pages shows 404 page. I will diging in a little bit more to see if I can get a prototype working

@arivera12
Copy link

arivera12 commented Oct 3, 2020

Ok I got it working.

I just needed to add and change some reference on program.cs on blazor wasm project

builder.RootComponents.Add<WebUI.App>("app");

and

builder.Services.AddSingleton<CounterState>();

I deleted everything else except the wwwroot folder since wwwoot on the base library is working as embedded resource I don't know how to load blazor site from a embedded resource.

Also I changed CounterState access modifier to public instead of internal to initialize it over blazor wasm project.

I also see we need to share or have in common some services with blazor wasm/server like for example CounterState.

For everything going on top of xamarin the default project is Ok.

But for blazor wasm and blazor server we may want to initialize others services that are web specific.

On xamarin we may want to use Xamarin.Essentials instead.

@arivera12
Copy link

arivera12 commented Oct 3, 2020

I propose making 3 folders for services on base project

Services/Common
Services/Web
Services/Native

On native apps we call common and native services.
On blazor wasm and server we call common and web services

@Eilon Eilon added the hybrid-apps Issues related to hybrid or web/HTML apps label Oct 5, 2020
@Eilon
Copy link
Member

Eilon commented Oct 27, 2020

This is in!!!!!! Fixed in #178

A huge huge huge HUGE thank you to @jspuij for all of his work, patience, and late night (for him) phone calls with me!

@Eilon Eilon closed this as completed Oct 27, 2020
@arivera12
Copy link

@Eilon when you gonna do a new template and nuget package version? I saw you are still having one more task for take out a new preview based on the current milestone. I am using nighly build at this moment but I saw @jspuij did some changes to the template structure, when we can have this template changes?

@Eilon
Copy link
Member

Eilon commented Oct 28, 2020

Hi @arivera12 the nightly feed has both the updated NuGet packages for the code as well as the NuGet packages that contain the templates!

Learn more here: https://docs.microsoft.com/mobile-blazor-bindings/contribute/nightly-builds

@Eilon
Copy link
Member

Eilon commented Oct 29, 2020

I've written up an initial walkthrough to guide people to build a Razor Class Library (RCL) and use it in a Mobile Blazor Bindings app and in a Blazor Web app.

You can check it out in the pre-publish format here: https://github.com/MicrosoftDocs/mobile-blazor-bindings/blob/master/mobile-blazor-bindings/walkthroughs/shared-web-ui.md

This will eventually go live on the Microsoft Docs site. But in the meantime please have a look if you'd like to learn more and let me know if you have any feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-mobileblazorbindings Experimental Mobile Bindings for Blazor hybrid-apps Issues related to hybrid or web/HTML apps
Projects
None yet
Development

No branches or pull requests

3 participants