BlazorMobile.Web
3.0.4-preview7.19365.7
See the version list below for details.
dotnet add package BlazorMobile.Web --version 3.0.4-preview7.19365.7
NuGet\Install-Package BlazorMobile.Web -Version 3.0.4-preview7.19365.7
<PackageReference Include="BlazorMobile.Web" Version="3.0.4-preview7.19365.7" />
paket add BlazorMobile.Web --version 3.0.4-preview7.19365.7
#r "nuget: BlazorMobile.Web, 3.0.4-preview7.19365.7"
// Install BlazorMobile.Web as a Cake Addin #addin nuget:?package=BlazorMobile.Web&version=3.0.4-preview7.19365.7&prerelease // Install BlazorMobile.Web as a Cake Tool #tool nuget:?package=BlazorMobile.Web&version=3.0.4-preview7.19365.7&prerelease
See documentation on BlazorMobile project page
Migration
BlazorMobile 0.8.0 to 3.0.3-preview7.19365.7
In your Blazor project, edit your *.csproj file:
- Remove the BlazorMobile.Common PackageReference
- Remove the manual PostBuild event, that look like this:
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="rm $(ProjectDir)\BuildTools\artifacts\app.zip >nul 2>&1
$(ProjectDir)\BuildTools\7za.exe a $(ProjectDir)\BuildTools\artifacts\app.zip $(ProjectDir)wwwroot\* -mx1 -tzip
$(ProjectDir)\BuildTools\7za.exe a $(ProjectDir)\BuildTools\artifacts\app.zip $(ProjectDir)$(OutputPath)dist\* -mx1 -tzip" />
</Target>
- In this same project file, add a PackageReference to BlazorMobile.Build and BlazorMobile.Web. This should look like this:
<ItemGroup>
<PackageReference Include="BlazorMobile.Build" Version="3.0.3-preview7.19365.7" />
<PackageReference Include="BlazorMobile.Web" Version="3.0.3-preview7.19365.7" />
<PackageReference Include="Microsoft.AspNetCore.Blazor" Version="3.0.0-preview7.19365.7" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.Build" Version="3.0.0-preview7.19365.7" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Blazor.DevServer" Version="3.0.0-preview7.19365.7" />
</ItemGroup>
- In all of your projects, update any reference of BlazorMobile or BlazorMobile.Common to the 3.0.3-preview7.19365.7 version.
In your Startup.cs file, in Configure, replace:
public void Configure(IComponentsApplicationBuilder app)
{
app.AddComponent<App>("app");
BlazorWebViewService.Init(app, "blazorXamarin", (bool success) =>
{
Console.WriteLine($"Initialization success: {success}");
Console.WriteLine("Device is: " + Device.RuntimePlatform);
});
}
to:
public void Configure(IComponentsApplicationBuilder app)
{
#if DEBUG
//Only if you want to test WebAssembly with remote debugging from a dev machine
BlazorService.EnableClientToDeviceRemoteDebugging("192.168.1.118", 8888);
#endif
BlazorService.Init(app, (bool success) =>
{
Console.WriteLine($"Initialization success: {success}");
Console.WriteLine("Device is: " + Device.RuntimePlatform);
});
app.AddComponent<MobileApp>("app");
}
Actually, change the onSuccess delegate to anything you want. But notice the MobileApp instead of App component.
You should create your own component inherited from App. Create a MobileApp.cs file in your Blazor project and copy/paste this:
using BlazorMobile.Common.Components;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.RenderTree;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace BlazorMobile.Sample.Blazor
{
public class MobileApp : App
{
protected override void BuildRenderTree(RenderTreeBuilder builder)
{
builder.OpenElement(0, nameof(BlazorMobileComponent));
builder.OpenComponent(1, typeof(BlazorMobileComponent));
builder.CloseComponent();
builder.CloseElement();
base.BuildRenderTree(builder);
}
}
}
Of course, replace the given namespaces by the one used by your own project.
- In your index.html from your Blazor project, you can safely remove the blazorXamarin tag.
- If you intent to use the server-mode to debug (see related documentation), you can also update the blazor script tag. In the current sample, index.html look like this:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>BlazorMobile.BlazorApp</title>
<base href="/" />
<link href="css/bootstrap/bootstrap.min.css" rel="stylesheet" />
<link href="css/site.css" rel="stylesheet" />
</head>
<body>
<app>Loading...</app>
<script type="text/javascript" src="js/blazor.polyfill.js"></script>
<script id="blazorMode"></script>
<script>
document.getElementById("blazorMode").src = window.location.search.includes("mode=server") ? "_framework/blazor.server.js" : "_framework/blazor.webassembly.js";
</script>
</body>
</html>
See the documentation, about how to switch from WASM to .NET Core debugging if needed.
- Update your RegisterAppStreamResolver code if needed. See the linking Blazor to Xamarin section for this.
- Add missing additionnals project if needed from samples, to your project.
New projects are:
- BlazorMobile.Sample.Blazor.Server, for testing your Blazor app with the .NET Core runtime
- BlazorMobile.Sample.UWP, for deploying your Blazor app to UWP (Windows 10).
BlazorMobile 3.0.3-preview7.19365.7 to 3.0.4-preview7.19365.7
In your Xamarin shared project, like BlazorMobile.Sample sample project you should:
- Inherit from BlazorApplication instead of Application in App.xaml.cs
using BlazorMobile.Components;
using BlazorMobile.Services;
using System;
using Xamarin.Forms;
namespace BlazorMobile.Sample
{
public partial class App : BlazorApplication
{
public App()
{
...Your code...
}
}
}
- Inherit from BlazorApplication instead of Application in App.xaml too. Your code should look like this:
<?xml version="1.0" encoding="utf-8" ?>
<components:BlazorApplication
xmlns:components="clr-namespace:BlazorMobile.Components;assembly=BlazorMobile"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="BlazorMobile.Sample.App">
<Application.Resources>
</Application.Resources>
</components:BlazorApplication>
- You should remove any WebApplicationFactory.StartWebServer and WebApplicationFactory.StopWebServer reference in your App.xaml.cs, as they are now internals and managed by the BlazorApplication class. You can safely remove theses lines:
protected override void OnStart()
{
WebApplicationFactory.StartWebServer();
}
protected override void OnSleep()
{
WebApplicationFactory.StopWebServer();
}
protected override void OnResume()
{
WebApplicationFactory.ResetBlazorViewIfHttpPortChanged();
WebApplicationFactory.StartWebServer();
}
NOTE: WebApplicationFactory.SetHttpPort is not mandatory anymore as if the app fail to bind on your specific port, it will fallback on another available port. But you can still use it for your specific needs and in order to assign a fixed port for remote debugging sessions.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.AspNetCore.Blazor (>= 3.0.0-preview7.19365.7)
- NETStandard.Library (>= 2.0.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on BlazorMobile.Web:
Package | Downloads |
---|---|
BlazorMobile.ElectronNET
This package allow BlazorMobile to be compatible with an ElectronNET server-side Blazor application, so you can use the same project structure and interoping calls either on Mobile (BlazorMobile) and Desktop (ElectronNET) |
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on BlazorMobile.Web:
Repository | Stars |
---|---|
Daddoon/BlazorMobile
Create full C# driven hybrid-apps for iOS, Android, UWP & Desktop with Blazor!
|
Version | Downloads | Last updated |
---|---|---|
3.2.8 | 4,046 | 6/5/2020 |
3.2.7-preview4.20210.8 | 379 | 5/4/2020 |
3.2.5-preview3.20168.3 | 365 | 4/13/2020 |
3.2.4-preview2.20160.5 | 330 | 3/27/2020 |
3.2.3-preview2.20160.5 | 302 | 3/21/2020 |
3.2.2-preview1.20073.1 | 388 | 3/7/2020 |
3.2.0-preview1.20073.1 | 358 | 2/7/2020 |
3.1.0-preview3.19555.2 | 389 | 11/21/2019 |
3.1.0-preview1.19508.20 | 317 | 10/31/2019 |
3.0.12-preview9.19465.2 | 305 | 10/11/2019 |
3.0.11-preview9.19465.2 | 395 | 10/6/2019 |
3.0.10-preview9.19424.4 | 396 | 9/8/2019 |
3.0.9-preview8.19405.7 | 307 | 9/1/2019 |
3.0.8-preview8.19405.7 | 300 | 8/27/2019 |
3.0.6-preview8.19405.7 | 323 | 8/18/2019 |
3.0.5-preview8.19405.7 | 295 | 8/14/2019 |
3.0.4-preview7.19365.7 | 290 | 8/12/2019 |
3.0.3-preview7.19365.7 | 304 | 8/4/2019 |
Updated NuGet package to be based on Blazor 3.0.0-preview7.19365.7. Remove dependencies on BlazorMobile.Common package.