Skip to content

Commit a4906d5

Browse files
authored
Fix wasm deployment issue (#827)
* fix: update wasm-tools installation * fix: add TrimmerRootAssembly for WASM optimization * fix: update project to target .NET 10 and adjust deployment settings * fix: add TrimmerRootAssembly for Ursa.Demo to improve WASM optimization * fix: avoid Window based dialog crash on non-supported platforms.
1 parent 1cf920a commit a4906d5

File tree

5 files changed

+29
-6
lines changed

5 files changed

+29
-6
lines changed

.github/workflows/deploy.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Deploy to GitHub Pages
22

33
env:
44
PROJECT_PATH: demo/Ursa.Demo.Browser/Ursa.Demo.Browser.csproj
5-
OUTPUT_PATH: demo/Ursa.Demo.Browser/bin/Release/net8.0-browser/publish/wwwroot
5+
OUTPUT_PATH: demo/Ursa.Demo.Browser/bin/Release/net10.0-browser/publish/wwwroot
66
on:
77
workflow_dispatch:
88

@@ -13,10 +13,10 @@ jobs:
1313
- name: Checkout
1414
uses: actions/[email protected]
1515

16-
- name: Setup .NET 8
17-
uses: actions/setup-dotnet@v4
16+
- name: Setup .NET 10
17+
uses: actions/setup-dotnet@v5
1818
with:
19-
dotnet-version: 8.0.x
19+
dotnet-version: 10.0.x
2020

2121
- name: Install wasm-tools
2222
run: dotnet workload install wasm-tools

demo/Ursa.Demo.Browser/Ursa.Demo.Browser.csproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk.WebAssembly">
22
<PropertyGroup>
3-
<TargetFramework>net8.0-browser</TargetFramework>
3+
<TargetFramework>net10.0-browser</TargetFramework>
44
<OutputType>Exe</OutputType>
55
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
66
<Nullable>enable</Nullable>
@@ -9,9 +9,15 @@
99
<ItemGroup>
1010
<AvaloniaResource Include="Assets\**"/>
1111
</ItemGroup>
12+
13+
<ItemGroup>
14+
<TrimmerRootAssembly Include="Ursa.Demo" />
15+
<TrimmerRootAssembly Include="Ursa.Demo.Browser" />
16+
</ItemGroup>
1217

1318
<ItemGroup>
1419
<PackageReference Include="Avalonia.Browser" Version="$(AvaloniaVersion)"/>
20+
<PackageReference Include="SkiaSharp.NativeAssets.WebAssembly" Version="3.119.1" />
1521
</ItemGroup>
1622

1723
<ItemGroup>

demo/Ursa.Demo/ViewModels/ButtonGroupDemoViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ public ButtonItem()
3030

3131
private async Task Invoke()
3232
{
33-
await MessageBox.ShowAsync("Hello " + Name);
33+
await MessageBox.ShowOverlayAsync("Hello " + Name);
3434
}
3535
}

demo/Ursa.Demo/ViewModels/DialogDemoViewModel.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ public DefaultWindowDialogDemoViewModel()
4848

4949
private async Task ShowDialog()
5050
{
51+
if(OperatingSystem.IsBrowser() || OperatingSystem.IsAndroid() || OperatingSystem.IsIOS())
52+
{
53+
await MessageBox.ShowOverlayAsync("Window dialogs are not supported on this platform. Please use overlay dialogs instead.");
54+
return;
55+
}
5156
var options = new DialogOptions()
5257
{
5358
Title = Title,
@@ -92,6 +97,11 @@ public CustomWindowDialogDemoViewModel()
9297

9398
private async Task ShowDialog()
9499
{
100+
if(OperatingSystem.IsBrowser() || OperatingSystem.IsAndroid() || OperatingSystem.IsIOS())
101+
{
102+
await MessageBox.ShowOverlayAsync("Window dialogs are not supported on this platform. Please use overlay dialogs instead.");
103+
return;
104+
}
95105
var options = new DialogOptions()
96106
{
97107
Title = Title,

demo/Ursa.Demo/ViewModels/MessageBoxDemoViewModel.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.ObjectModel;
33
using System.Threading.Tasks;
44
using System.Windows.Input;
5+
using Avalonia.Markup.Xaml.MarkupExtensions;
56
using CommunityToolkit.Mvvm.ComponentModel;
67
using CommunityToolkit.Mvvm.Input;
78
using Ursa.Controls;
@@ -126,6 +127,12 @@ private async Task Show(MessageBoxButton button)
126127
}
127128
else
128129
{
130+
if (OperatingSystem.IsBrowser() || OperatingSystem.IsAndroid() || OperatingSystem.IsIOS())
131+
{
132+
await MessageBox.ShowOverlayAsync("Only overlay message box is supported on this platform.",
133+
"Ursa MessageBox", button: MessageBoxButton.OK, icon: MessageBoxIcon.Error);
134+
return;
135+
}
129136
Result = await MessageBox.ShowAsync(_message, _title, icon: SelectedIcon, button:button);
130137
}
131138
}

0 commit comments

Comments
 (0)