Resolve SkiaSharp Build Issues in .NET 11 Blazor WebAssembly
11 Nov 20262 minutes to read
Currently, SkiaSharp does not officially support .NET 11. In addition, Syncfusion® uses the older SkiaSharp 4.150.1 packages. As a workaround, the Blazor WebAssembly sample can be built and run successfully by manually upgrading the SkiaSharp packages to 4.154.0.
This workaround enables the Blazor WebAssembly sample to work with .NET 11 until official .NET 11 support is provided by the SkiaSharp team.
Upgrade the SkiaSharp packages
Upgrade the following SkiaSharp packages to version 4.154.0 in your project.
<PackageReference Include="SkiaSharp.HarfBuzz" Version="4.154.0" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="4.154.0" />
<PackageReference Include="SkiaSharp.Views.Blazor" Version="4.154.0" />Alternatively, you can use the following package manager commands.
Install-Package SkiaSharp.HarfBuzz -Version 4.154.0
Install-Package SkiaSharp.NativeAssets.Linux -Version 4.154.0
Install-Package SkiaSharp.Views.Blazor -Version 4.154.0dotnet add package SkiaSharp.HarfBuzz -v 4.154.0
dotnet add package SkiaSharp.NativeAssets.Linux -v 4.154.0
dotnet add package SkiaSharp.Views.Blazor -v 4.154.0
dotnet restoreInclude the required native static libraries
.NET 11 uses the Emscripten 5.0.6 tool chain to build WebAssembly applications, while the SkiaSharp 4.154.0 package ships the native static libraries for the Emscripten 3.1.34 and 3.1.56 tool chains. Therefore, you must include the required native static libraries in the .csproj file to build the application successfully.
Add the following workaround to the .csproj file.
<ItemGroup>
<NativeFileReference Include="$(SkiaSharpStaticLibraryPath)\5.0.6\st*.a" />
</ItemGroup>
- The
$(SkiaSharpStaticLibraryPath)property is defined by theSkiaSharp.NativeAssets.WebAssemblypackage, which is included as a dependency of theSkiaSharp.Views.Blazorpackage.- The
5.0.6folder contains the native static libraries built with the Emscripten 5.0.6 tool chain used by .NET 11.- The
st*.apattern refers to the single-threaded static libraries. Usemt*.ainstead if the application enables multithreading.
See also
- Getting Started with the Blazor PDF Viewer in a Blazor Web App
- Getting Started with the Blazor PDF Viewer in a Blazor WebAssembly App
- How to Reduce slowness when running the WASM sample in Visual Studio
- .NET 9 Native Linking Issues with SkiaSharp and Emscripten 3.1.56
- SkiaSharp.NativeAssets.WebAssembly no longer compatible with .NET 11 WASM
- Unable to Build Blazor WASM Application on .NET 11 with SkiaSharp.Views.Blazor