Skip to content

Commit 26def4e

Browse files
committed
Fixes
1 parent 31fbf2d commit 26def4e

5 files changed

Lines changed: 39 additions & 2 deletions

File tree

.github/workflows/deploy-blazor-sample.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,15 @@ jobs:
4242
with:
4343
dotnet-version: '10.0.x'
4444

45+
# wasm-tools has to be named explicitly: `dotnet workload restore` installs nothing for a
46+
# Blazor WebAssembly project, and without the workload the SkiaSharp native relink is skipped
47+
# silently — the publish succeeds and every Office view then throws
48+
# "DllNotFoundException: libSkiaSharp" in the browser. The guard imported by Sample.Blazor.csproj
49+
# turns that back into a build failure, but the workload is what actually fixes it.
4550
- name: Restore workloads
46-
run: dotnet workload restore "${{ env.SAMPLE_CSPROJ }}"
51+
run: |
52+
dotnet workload install wasm-tools
53+
dotnet workload restore "${{ env.SAMPLE_CSPROJ }}"
4754
4855
- name: Publish
4956
run: dotnet publish "${{ env.SAMPLE_CSPROJ }}" -c Release -o publish

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,9 @@ await workbook.SaveAsync();
905905
| Reporting | `UnsupportedFeatureCollector` names anything in a document the editor cannot show or edit |
906906

907907
**Constraints.** Blazor is **WebAssembly only** (a Server round-trip per keystroke is unusable, and
908-
SkiaSharp on WASM needs the `wasm-tools` workload). MAUI requires `UseSkiaSharp()`. Inserting and
908+
SkiaSharp on WASM needs the `wasm-tools` workload — without it `libSkiaSharp` is never linked into the
909+
runtime and the app fails in the browser, so `Shiny.Blazor.Controls.Office` fails the build up front
910+
with `SHINY0001` instead; bypass with `ShinySkipWasmToolsCheck=true`). MAUI requires `UseSkiaSharp()`. Inserting and
909911
deleting rows and columns is deliberately not implemented — it requires rewriting references across
910912
formulas, merged cells, conditional formatting, defined names, data validation, charts and tables.
911913

samples/Sample.Blazor/Sample.Blazor.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
<RootNamespace>Sample.Blazor</RootNamespace>
66
</PropertyGroup>
77

8+
<!-- ProjectReference does not flow a package's buildTransitive targets, so the wasm-tools guard
9+
that ships in Shiny.Blazor.Controls.Office is imported by hand here — this sample publishes
10+
to GitHub Pages and a missing workload silently ships a broken Office demo. -->
11+
<Import Project="..\..\src\Shiny.Blazor.Controls.Office\buildTransitive\Shiny.Blazor.Controls.Office.targets" />
12+
813
<ItemGroup>
914
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly"/>
1015
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" PrivateAssets="all"/>

src/Shiny.Blazor.Controls.Office/Shiny.Blazor.Controls.Office.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@
77
<Description>Spreadsheet viewer and editor for Blazor WebAssembly, rendering .xlsx on a SkiaSharp canvas.</Description>
88
</PropertyGroup>
99

10+
<ItemGroup>
11+
<!-- Fails the consumer's build when the wasm-tools workload is missing, instead of letting
12+
them publish an app that dies on the first Skia call. See the targets file. -->
13+
<None Include="buildTransitive/Shiny.Blazor.Controls.Office.targets" Pack="true" PackagePath="buildTransitive/Shiny.Blazor.Controls.Office.targets" />
14+
</ItemGroup>
15+
1016
<ItemGroup>
1117
<SupportedPlatform Include="browser" />
1218
<PackageReference Include="Microsoft.AspNetCore.Components.Web"/>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2+
<!--
3+
Every Office view paints through SkiaSharp, and SkiaSharp for WebAssembly ships only a static
4+
libSkiaSharp.a. It is linked into the runtime by the native relink step, which runs only when the
5+
wasm-tools workload is installed. Without the workload the NativeFileReference is silently
6+
dropped: restore, build and publish all succeed, and the first Skia call in the browser throws
7+
"DllNotFoundException: libSkiaSharp" with a blank canvas behind it. Fail the build instead.
8+
-->
9+
<Target
10+
Name="_ShinyBlazorControlsOfficeCheckWasmTools"
11+
BeforeTargets="PrepareForBuild"
12+
Condition="'$(RuntimeIdentifier)' == 'browser-wasm' AND '$(WasmNativeWorkloadAvailable)' != 'true' AND '$(ShinySkipWasmToolsCheck)' != 'true'">
13+
<Error
14+
Code="SHINY0001"
15+
Text="Shiny.Blazor.Controls.Office renders with SkiaSharp, which needs the 'wasm-tools' workload so that libSkiaSharp gets linked into the WebAssembly runtime. Install that workload (`dotnet workload install wasm-tools`) — note that `dotnet workload restore` does NOT pull it in for a Blazor WebAssembly project. Without it the app builds and publishes clean, then fails in the browser with DllNotFoundException: libSkiaSharp. Set ShinySkipWasmToolsCheck=true to bypass this check." />
16+
</Target>
17+
</Project>

0 commit comments

Comments
 (0)