Skip to content

Commit b65923f

Browse files
chore: v1.0.5 (#3)
* feat: WebView2 installer * chore: Bump Microsoft.AspNetCore.Components.WebView.Wpf to 6.0.200-preview.13.2865 * fix: pipeline * chore: bump Blazor Desktop to v1.0.5 * fix: pipeline
1 parent ba80f19 commit b65923f

9 files changed

Lines changed: 47 additions & 16 deletions

File tree

.github/workflows/lint-code.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ jobs:
2020
- name: Set up .NET
2121
uses: actions/setup-dotnet@v1
2222
with:
23-
dotnet-version: "6.0.x"
24-
25-
- name: Install dotnet-format
26-
run: dotnet tool install -g dotnet-format
23+
dotnet-version: "6.0.101"
2724

2825
- name: Run linters
2926
uses: AndrewBabbitt97/[email protected]

.github/workflows/scan-code.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ on:
1313
jobs:
1414
scan-code:
1515
name: Scan Code
16-
runs-on: windows-latest
16+
runs-on: windows-2019
1717

1818
permissions:
1919
actions: read

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Blazor Desktop allows you to create desktop apps using Blazor. Apps run inside o
1010
The easiest way to get started with Blazor Desktop is to install the templates, you can do so using the dotnet cli as follows:
1111

1212
```powershell
13-
dotnet new --install BlazorDesktop.Templates::1.0.4
13+
dotnet new --install BlazorDesktop.Templates::1.0.5
1414
```
1515

1616
Once you have the templates installed, you can either create a new project from the template either in Visual Studio in the template picker:
@@ -92,6 +92,11 @@ It is also possible to configure these values through `appsettings.json` like so
9292
}
9393
```
9494

95+
Blazor Desktop will automatically install WebView2 for the user if they do not already have it installed, you can disable this if you wish:
96+
```csharp
97+
builder.Window.UseWebView2Installer(false);
98+
```
99+
95100
**The `Window` object itself is also made available inside of the DI container, so you can access all properties on it by using the inject Razor keyword or requesting it through the constructor of a class added as a service.**
96101

97102
## Custom Window Chrome & Draggable Regions

src/BlazorDesktop.Templates/BlazorDesktop.Templates.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<PackageType>Template</PackageType>
5-
<PackageVersion>1.0.4</PackageVersion>
5+
<PackageVersion>1.0.5</PackageVersion>
66
<PackageId>BlazorDesktop.Templates</PackageId>
77
<Title>Blazor Desktop Templates</Title>
88
<Authors>Andrew Babbitt</Authors>

src/BlazorDesktop.Templates/templates/BlazorDesktop-CSharp/BlazorDesktop-CSharp.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</PropertyGroup>
1010

1111
<ItemGroup>
12-
<PackageReference Include="BlazorDesktop" Version="1.0.4" />
12+
<PackageReference Include="BlazorDesktop" Version="1.0.5" />
1313
</ItemGroup>
1414

1515
</Project>

src/BlazorDesktop/BlazorDesktop.csproj

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
2929
<PackageIcon>nuget.png</PackageIcon>
3030
<RepositoryType>git</RepositoryType>
31-
<AssemblyVersion>1.0.4.0</AssemblyVersion>
32-
<FileVersion>1.0.4.0</FileVersion>
33-
<Version>1.0.4</Version>
31+
<AssemblyVersion>1.0.5.0</AssemblyVersion>
32+
<FileVersion>1.0.5.0</FileVersion>
33+
<Version>1.0.5</Version>
3434
<IncludeSymbols>true</IncludeSymbols>
3535
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
3636
</PropertyGroup>
@@ -47,7 +47,8 @@
4747
</ItemGroup>
4848

4949
<ItemGroup>
50-
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Wpf" Version="6.0.101-preview.11.2349" />
50+
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Wpf" Version="6.0.200-preview.13.2865" />
51+
<PackageReference Include="WebView2.Runtime.AutoInstaller" Version="1.0.0" />
5152
</ItemGroup>
5253

5354
<PropertyGroup>

src/BlazorDesktop/Hosting/ConfigureWindowBuilder.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,4 +88,15 @@ public ConfigureWindowBuilder UseIcon(string icon)
8888
_config[WindowDefaults.Icon] = icon;
8989
return this;
9090
}
91+
92+
/// <summary>
93+
/// If the WebView2 installer should be used.
94+
/// </summary>
95+
/// <param name="installer">If the WebView2 installer should be used.</param>
96+
/// <returns>The <see cref="ConfigureWindowBuilder"/>.</returns>
97+
public ConfigureWindowBuilder UseWebView2Installer(bool installer)
98+
{
99+
_config[WindowDefaults.WebView2Installer] = installer.ToString();
100+
return this;
101+
}
91102
}

src/BlazorDesktop/Hosting/WindowDefaults.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,9 @@ public static class WindowDefaults
3838
/// The configuration key associated with the icon.
3939
/// </summary>
4040
public static readonly string Icon = "window:icon";
41+
42+
/// <summary>
43+
/// The configuration key associated with the WebView2 installer.
44+
/// </summary>
45+
public static readonly string WebView2Installer = "window:webView2Installer";
4146
}

src/BlazorDesktop/Services/BlazorDesktopService.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
using System.Diagnostics.CodeAnalysis;
66
using System.Windows;
7+
using BlazorDesktop.Hosting;
8+
using WebView2.Runtime.AutoInstaller;
79

810
namespace BlazorDesktop.Services;
911

@@ -27,35 +29,45 @@ public class BlazorDesktopService : IHostedService, IDisposable
2729
/// </summary>
2830
private readonly IServiceProvider _services;
2931

32+
/// <summary>
33+
/// The configuration.
34+
/// </summary>
35+
private readonly IConfiguration _config;
36+
3037
/// <summary>
3138
/// Creates a <see cref="BlazorDesktopService"/> instance.
3239
/// </summary>
3340
/// <param name="lifetime">The <see cref="IHostApplicationLifetime"/>.</param>
3441
/// <param name="services">The <see cref="IServiceProvider"/>.</param>
35-
public BlazorDesktopService(IHostApplicationLifetime lifetime, IServiceProvider services)
42+
/// <param name="config">The <see cref="IConfiguration"/>.</param>
43+
public BlazorDesktopService(IHostApplicationLifetime lifetime, IServiceProvider services, IConfiguration config)
3644
{
3745
_applicationStoppingRegistration = new();
3846
_lifetime = lifetime;
3947
_services = services;
48+
_config = config;
4049
}
4150

4251
/// <summary>
4352
/// Starts the service.
4453
/// </summary>
4554
/// <param name="cancellationToken">The cancellation token.</param>
4655
/// <returns>A task that represents starting the service.</returns>
47-
public Task StartAsync(CancellationToken cancellationToken)
56+
public async Task StartAsync(CancellationToken cancellationToken)
4857
{
4958
_applicationStoppingRegistration = _lifetime.ApplicationStopping.Register(() =>
5059
{
5160
OnApplicationStopping();
5261
});
5362

63+
if (_config.GetValue<bool?>(WindowDefaults.WebView2Installer) ?? true)
64+
{
65+
await WebView2AutoInstaller.CheckAndInstallAsync(silentInstall: false, cancellationToken: cancellationToken);
66+
}
67+
5468
var thread = new Thread(ApplicationThread);
5569
thread.SetApartmentState(ApartmentState.STA);
5670
thread.Start();
57-
58-
return Task.CompletedTask;
5971
}
6072

6173
/// <summary>

0 commit comments

Comments
 (0)