Skip to content

Latest commit

 

History

History
223 lines (161 loc) · 15.9 KB

File metadata and controls

223 lines (161 loc) · 15.9 KB

NuGet Packages

Reference for all NuGet packages produced by SkiaSharp — purpose, contents, and usage guidance.

Related: Adding Libraries | Architecture

Contents


Core Managed Packages

These contain the managed C# assemblies. The SkiaSharp and HarfBuzzSharp core packages automatically include the appropriate NativeAssets for most platforms (see Auto-Included NativeAssets). For Linux, WebAssembly, NanoServer, and WinUI you must add the NativeAssets package manually.

Package Description
SkiaSharp Cross-platform 2D graphics API. Managed C# bindings to Google's Skia library. Core types: SKCanvas, SKPaint, SKBitmap, SKImage, SKPath, SKSurface.
HarfBuzzSharp Managed C# bindings to the HarfBuzz text shaping engine. Provides Buffer, Font, Face for complex text layout.
SkiaSharp.HarfBuzz Integration bridge — adds HarfBuzz text shaping to SkiaSharp via SKShaper. Depends on both SkiaSharp and HarfBuzzSharp.
SkiaSharp.Skottie Lottie/Bodymovin animation playback. Renders After Effects animations. Depends on SkiaSharp, SkiaSharp.SceneGraph, and SkiaSharp.Resources.
SkiaSharp.SceneGraph Scene graph API for complex rendering pipelines. Depends on SkiaSharp. Used by Skottie internally.
SkiaSharp.Resources Resource provider implementations. Depends on SkiaSharp. Used by Skottie for asset loading.

Views Packages

Platform-specific UI controls for rendering SkiaSharp content. These provide ready-to-use views/controls that handle the platform-specific rendering surface setup.

Package Description
SkiaSharp.Views Platform views for iOS, tvOS, macOS, Mac Catalyst, Android, and Tizen. Provides SKCanvasView and SKGLView.
SkiaSharp.Views.Desktop.Common Common base classes for desktop views (netstandard2.0+, net462+).
SkiaSharp.Views.WindowsForms Windows Forms controls: SKControl, SKGLControl. net462+ and net6.0-windows+. Depends on OpenTK.
SkiaSharp.Views.WPF WPF control: SKElement. net462+ and net6.0-windows+. Depends on OpenTK.
SkiaSharp.Views.WinUI WinUI 3 controls: SKXamlCanvas, SKSwapChainPanel. net6.0-windows+. Depends on Microsoft.WindowsAppSDK. Auto-includes SkiaSharp.NativeAssets.WinUI.
SkiaSharp.Views.Gtk3 GTK# 3 control: SKDrawingArea. netstandard2.0+. For Linux desktop apps. Depends on GtkSharp.
SkiaSharp.Views.Blazor Blazor WebAssembly controls: SKCanvasView, SKGLView. net6.0+ (WASM native assets require net8.0+). Auto-includes SkiaSharp.NativeAssets.WebAssembly.
SkiaSharp.Views.Maui.Core .NET MAUI shared view infrastructure. net8.0+. Depends on Microsoft.Maui.Core.
SkiaSharp.Views.Maui.Controls .NET MAUI controls: SKCanvasView, SKGLView. net8.0+. Depends on SkiaSharp.Views.Maui.Core and Microsoft.Maui.Controls.
SkiaSharp.Views.Uno.WinUI Uno Platform controls: SKXamlCanvas, SKSwapChainPanel. net8.0+. Depends on Uno.WinUI. Auto-includes SkiaSharp.NativeAssets.WebAssembly for WASM targets and SkiaSharp.Views.WinUI for Windows targets.

GPU Backend Packages

Optional packages for hardware-accelerated rendering via specific GPU APIs.

Package Description
SkiaSharp.Vulkan.SharpVk Vulkan GPU backend. netstandard2.0+, net462+, net6.0+. Depends on SharpVk 0.4.2.
SkiaSharp.Direct3D.Vortice Direct3D 12 GPU backend. net8.0 only. Windows-only due to Vortice.Direct3D12 3.5.0 dependency.

Native Assets

Each platform has a pair of NativeAssets packages containing pre-built native binaries:

  • SkiaSharp.NativeAssets.{Platform} — contains libSkiaSharp
  • HarfBuzzSharp.NativeAssets.{Platform} — contains libHarfBuzzSharp

Both follow the same platform matrix and architectures. HarfBuzzSharp does not have Linux.NoDependencies, NanoServer, or WinUI variants.

Important: Library projects should depend on SkiaSharp only. NativeAssets packages belong in the application (executable) project so the correct binary is deployed. See Deployment & Containers.

Platform Packages

Package Description
SkiaSharp.NativeAssets.Win32
HarfBuzzSharp.NativeAssets.Win32
Windows (x64, x86, arm64). Auto-included.
SkiaSharp.NativeAssets.macOS
HarfBuzzSharp.NativeAssets.macOS
macOS universal binary (Intel + Apple Silicon). Auto-included.
SkiaSharp.NativeAssets.Linux
HarfBuzzSharp.NativeAssets.Linux
Linux (x64, x86, arm, arm64, riscv64, loongarch64). Both glibc and musl (Alpine) variants. Must add manually. Requires fontconfig (libfontconfig.so.1) for system font enumeration.
SkiaSharp.NativeAssets.Linux.NoDependencies Linux (same architectures as above, glibc + musl). SkiaSharp only. Must add manually. No fontconfig, no third-party deps — only requires libc/libm/libpthread/libdl. Designed for minimal containers. Fonts must be loaded explicitly.
SkiaSharp.NativeAssets.NanoServer Windows Nano Server containers (x64 only). SkiaSharp only. Must add manually.
SkiaSharp.NativeAssets.WinUI ANGLE rendering surface for WinUI 3 apps (x64, x86, arm64). SkiaSharp only. Contains SkiaSharp.Views.WinUI.Native.dll, libEGL.dll, and libGLESv2.dll for hardware-accelerated OpenGL ES — this is not a Skia binary. Auto-included by SkiaSharp.Views.WinUI.
SkiaSharp.NativeAssets.Android
HarfBuzzSharp.NativeAssets.Android
Android (x86, x64, arm, arm64). Auto-included.
SkiaSharp.NativeAssets.iOS
HarfBuzzSharp.NativeAssets.iOS
iOS framework bundle (arm64 device + simulator). Auto-included.
SkiaSharp.NativeAssets.MacCatalyst
HarfBuzzSharp.NativeAssets.MacCatalyst
Mac Catalyst universal framework bundle. Auto-included.
SkiaSharp.NativeAssets.tvOS
HarfBuzzSharp.NativeAssets.tvOS
Apple tvOS framework bundle (arm64, device only). Auto-included.
SkiaSharp.NativeAssets.Tizen
HarfBuzzSharp.NativeAssets.Tizen
Samsung Tizen (armel, x86). Auto-included.
SkiaSharp.NativeAssets.WebAssembly
HarfBuzzSharp.NativeAssets.WebAssembly
Emscripten static library (.a). Static linking, not P/Invoke — linked into dotnet.wasm at build time via MSBuild NativeFileReference. Includes Emscripten 3.1.34 (net8.0), 3.1.56 (net9.0/net10.0), and 5.0.6 (net11.0+) with threading (st/mt) and SIMD variants. Requires net8.0+. Must add manually (or use SkiaSharp.Views.Blazor / SkiaSharp.Views.Uno.WinUI).

⚠️ WASM is NOT dynamic loading. Unlike all other platforms, WebAssembly uses static linking at compile time. The .a files are passed to the Emscripten linker which embeds them into the final dotnet.wasm binary. DllImport("libSkiaSharp") still works — the .NET WASM runtime resolves it to statically linked symbols.

Unity WebGL: Unity WebGL also uses Emscripten. While not officially supported, the same static linking principle applies. Unity-specific integration may require manual configuration beyond the standard NativeFileReference approach.

Auto-Included NativeAssets

The core SkiaSharp and HarfBuzzSharp packages automatically include NativeAssets for most platforms via TFM-conditional dependencies:

Packages Auto-included when targeting
SkiaSharp.NativeAssets.Win32
HarfBuzzSharp.NativeAssets.Win32
Windows TFM (net8.0-windows) or non-platform TFM (net6.0, net8.0, netstandard2.0, netstandard2.1, net462)
SkiaSharp.NativeAssets.macOS
HarfBuzzSharp.NativeAssets.macOS
macOS TFM (net8.0-macos) or non-platform TFM (net6.0, net8.0, netstandard2.0, netstandard2.1, net462)
SkiaSharp.NativeAssets.Android
HarfBuzzSharp.NativeAssets.Android
Android TFM (net8.0-android)
SkiaSharp.NativeAssets.iOS
HarfBuzzSharp.NativeAssets.iOS
iOS TFM (net8.0-ios)
SkiaSharp.NativeAssets.MacCatalyst
HarfBuzzSharp.NativeAssets.MacCatalyst
Mac Catalyst TFM (net8.0-maccatalyst)
SkiaSharp.NativeAssets.tvOS
HarfBuzzSharp.NativeAssets.tvOS
tvOS TFM (net8.0-tvos)
SkiaSharp.NativeAssets.Tizen
HarfBuzzSharp.NativeAssets.Tizen
Tizen TFM (net8.0-tizen)

Must be added manually (not auto-included):

  • SkiaSharp.NativeAssets.Linux / HarfBuzzSharp.NativeAssets.Linux — for Linux server/desktop
  • SkiaSharp.NativeAssets.Linux.NoDependencies — for minimal Linux containers (SkiaSharp only)
  • SkiaSharp.NativeAssets.WebAssembly / HarfBuzzSharp.NativeAssets.WebAssembly — for Blazor/Uno WASM. SkiaSharp.NativeAssets.WebAssembly is auto-included by SkiaSharp.Views.Blazor and SkiaSharp.Views.Uno.WinUI; HarfBuzzSharp.NativeAssets.WebAssembly must always be added manually.
  • SkiaSharp.NativeAssets.NanoServer — for Windows Nano Server (SkiaSharp only)
  • SkiaSharp.NativeAssets.WinUI — for WinUI 3 apps (SkiaSharp only; auto-included by SkiaSharp.Views.WinUI)

Linux Package Selection Guide

Scenario Package Why
Standard Linux server/desktop SkiaSharp.NativeAssets.Linux Full fontconfig integration for system font access
Docker containers (Debian/Ubuntu) SkiaSharp.NativeAssets.Linux.NoDependencies No system library dependencies beyond glibc
Alpine Docker containers SkiaSharp.NativeAssets.Linux.NoDependencies Includes linux-musl-* variants, no deps
Minimal/distroless containers SkiaSharp.NativeAssets.Linux.NoDependencies Zero third-party deps
App needs system font enumeration SkiaSharp.NativeAssets.Linux Fontconfig required for SKFontManager system fonts

Deployment & Containers

Application vs Library References

NativeAssets packages must be referenced in the application project (the one that produces the executable), not in library projects. The .NET runtime resolves native binaries from the application's output directory using runtime identifiers (RIDs).

If a NativeAssets package is only referenced in a transitive library, the native binary may not be copied to the final output — causing DllNotFoundException at runtime.

Container Deployment

For containers, use SkiaSharp.NativeAssets.Linux.NoDependencies unless you specifically need fontconfig for system font enumeration. This package has zero third-party dependencies and works in minimal base images (mcr.microsoft.com/dotnet/aspnet, Alpine, distroless).

Publishing Modes

Mode Native Binary Handling
Framework-dependent Binaries in runtimes/{rid}/native/ resolved at runtime
Self-contained Binaries copied to publish output for the specified RID
Single-file Binaries extracted alongside the executable at runtime

Obsolete Packages

These packages are no longer actively maintained. Use the listed replacement.

Package Replacement
SkiaSharp.NativeAssets.UWP SkiaSharp.NativeAssets.WinUI
SkiaSharp.NativeAssets.watchOS (none — watchOS not supported)
HarfBuzzSharp.NativeAssets.UWP HarfBuzzSharp.NativeAssets.Win32
HarfBuzzSharp.NativeAssets.watchOS (none)
SkiaSharp.Views.NativeAssets.UWP SkiaSharp.Views.WinUI
SkiaSharp.Views.Forms SkiaSharp.Views.Maui.Controls
SkiaSharp.Views.Forms.WPF SkiaSharp.Views.WPF
SkiaSharp.Views.Forms.GTK SkiaSharp.Views.Gtk3
SkiaSharp.Views.Gtk2 SkiaSharp.Views.Gtk3
SkiaSharp.Views.Uno SkiaSharp.Views.Uno.WinUI
SkiaSharp.Views.Maui.Controls.Compatibility SkiaSharp.Views.Maui.Controls

Troubleshooting: Native Loading

Understanding DllNotFoundException on Linux

On Linux, DllNotFoundException errors from dlopen() have two distinct failure modes with different root causes:

Error pattern What happened Fix
libSkiaSharp.so: cannot open shared object file: No such file or directory The .so file was not found at any search path Add SkiaSharp.NativeAssets.Linux (or .NoDependencies) as a PackageReference in the executable project, not a library
libfontconfig.so.1: cannot open shared object file (or another dependency OF libSkiaSharp) A .so was found and loaded, but it has a dependency that isn't installed Either install the missing library (e.g. fontconfig) or switch to NoDependencies (see below)

Wrong Binary Deployed

SkiaSharp.NativeAssets.Linux.NoDependencies ships a .so with zero external dependencies — only libc/libm/libpthread/libdl. If you reference NoDependencies but see errors about missing fontconfig, uuid, or other libraries:

  1. The binary being loaded is not from NoDependencies — it's from NativeAssets.Linux (or another source)
  2. Check for a transitive SkiaSharp.NativeAssets.Linux reference conflicting with NoDependencies
  3. Check that NoDependencies is in the executable project (not a library project)
  4. Check your container build tool (e.g. .NET Aspire, Docker SDK) — it may deploy the wrong RID variant

You can verify which binary is loaded by running ldd on the libSkiaSharp.so in your publish output. The NoDependencies variant will show only libc/libm/libpthread/libdl.

Reading .NET Native Loading Errors

The .NET runtime tries multiple paths to load a native library and reports ALL failures. Focus on the first error — subsequent lines are fallback attempts:

System.DllNotFoundException: Unable to load shared library 'libSkiaSharp'
  libfontconfig.so.1: cannot open shared object file     ← LOOK HERE (binary found, dependency missing)
  /usr/share/dotnet/.../libSkiaSharp.so: cannot open      ← fallback path, file not found
  /app/liblibSkiaSharp.so: cannot open                    ← fallback path, file not found

Container Deployment Checklist

Problem Cause Fix
DllNotFoundException: libSkiaSharp Native binary not in output Add NativeAssets.Linux.NoDependencies (or .Linux) as a direct PackageReference in the application project
libfontconfig.so.1: cannot open Using NativeAssets.Linux in a minimal container Switch to NoDependencies, or install fontconfig in your Dockerfile
Wrong binary for container arch RID mismatch (glibc vs musl) Alpine needs linux-musl-* RIDs — NoDependencies includes both glibc and musl variants
Trimming removes native deps .NET trimmer strips unused assemblies Add the NativeAssets package as a direct PackageReference

Related Documentation