-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Blazor Desktop
- Install required .NET MAUI dependencies described in the .NET MAUI Development Guide.
- Follow the other instructions on that guide for how to build, open the solution, etc.
- On VS Windows use the
Microsoft.Maui-net6.slnsolution, and on VS Mac use theMicrosoft.Maui-mac.slnfsolution filter
The area/blazor 🕸️ label is used to track Blazor items: https://github.com/dotnet/maui/issues?q=is%3Aissue+is%3Aopen+label%3A%22area%2Fblazor+%F0%9F%95%B8%EF%B8%8F%22
This private project is used for triaging/prioritization: https://github.com/orgs/dotnet/projects/81/views/1
The Blazor-related projects in the repo are mostly located in the src/BlazorWebView folder, aside from the MAUI sample app:
| WinForms | WPF | .NET MAUI |
|---|---|---|
| source | source | source |
| - | - | templates |
| sample | sample | sample code, and sample app |
| - | - | tests |
The main component on each platform is the BlazorWebView control. They each have a unique implementation in the source locations above, though they do use some shared source for Windows/WebView2 related code.
The core WebView integration with Blazor is handled within the dotnet/aspnetcore repo here.
Sometimes it may be necessary to make changes in dotnet/aspnetcore, and react to the changes in this repo. The following are steps which outline the general process in using ASP.NET Core development nupkgs with MAUI.
-
Checkout
dotnet/aspnetcore, and follow the initialization instructions in the Build From Source guide. -
./restore.cmd -
. ./activate.ps1 -
Make the desired changes in
dotnet/aspnetcore. -
./eng/build.cmd -pack. The-packoption causes the creation of NuGet packages.- Note packing the full repo is only required upon the first change. Subsequent changes are likely to be isolated in
src/Components, hence you should be able too use.\src\Components\build.cmd -pack.
- Note packing the full repo is only required upon the first change. Subsequent changes are likely to be isolated in
-
You should see the generated packages in the
aspnetcore\artifacts\packages\Debug\NonShippingdirectory. The packages should end withx.0.0-dev.nupkgwherexis the current (pre-release) .NET version ORy.0.patch.nupkgwhereyis the current (released) .NET version andpatchis the current patch version (ex.6.0.4.nupkg). We'll refer to the version seen here asVERSIONin subsequent steps. -
Open
razor-tooling/NuGet.configand add the local package sources:dotnet nuget add source "<PATH_TO_ASPNET_CORE_REPO>\artifacts\packages\Debug\Shipping\" --name "ASPNETCORE_SHIPPING"dotnet nuget add source "<PATH_TO_ASPNET_CORE_REPO>\artifacts\packages\Debug\NonShipping\" --name "ASPNETCORE_NONSHIPPING"
-
Open
maui/eng/Versions.propsand update all theMicrosoftAspNetCore*PackageVersionandMicrosoftJSInteropPackageVersionto reflect theVERSION. -
Go to
<USER_HOME>\.nuget\packages\microsoft.aspnetcore.components.webviewand delete the directory namedVERSION. This clears the nuget cache. -
Run
dotnet restorein the directory for the app you're trying the experimental aspnetcore changes in (ex.\src\BlazorWebView\samples\BlazorWpfApp). -
You can now run the application and it'll use the experimental aspnetcore changes. Note, subsequent changes in the
aspnetcorerepo will require rebuilding (.\src\Components\build.cmd -pack) and repeating the previous two steps (clear nuget cache, rundotnet restore).
Go to this channel (and request to join if you don't have access).
Watch the recording of a brownbag session on working on Blazor Hybrid (Microsoft internal)