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.0
dotnet 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 restore

Include 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 the SkiaSharp.NativeAssets.WebAssembly package, which is included as a dependency of the SkiaSharp.Views.Blazor package.
  • The 5.0.6 folder contains the native static libraries built with the Emscripten 5.0.6 tool chain used by .NET 11.
  • The st*.a pattern refers to the single-threaded static libraries. Use mt*.a instead if the application enables multithreading.

See also