Windows AI Samples

An app that demonstrates how to use the Windows AI APIs with WinUI.

Windows App SDK versions

The same solution supports both stable and experimental Windows App SDK packages:

  • Stable packages build the stable scenarios, including Video Scaler.
  • Experimental packages also build the Image Foreground Extractor extension.

Experimental scenarios are separate projects under Extensions. Stable builds do not reference or build those projects. The main app conditionally links each extension's navigation registration file (for example, ImageForegroundExtractorNavigation.cs), so navigation is composed at compile time without runtime discovery.

Prerequisites

To get the latest updates to Windows and the development tools, and to help shape their development, join the Windows Insider Program.

Building and running the sample

  • Open the solution file (.sln) in Visual Studio.
  • From Visual Studio, either Start Without Debugging (Ctrl+F5) or Start Debugging (F5).

The root Samples/Directory.Packages.props file selects the Windows App SDK version and derives the channel automatically. From the repository root, select a stable package and build this sample with:

.\UpdateVersions.ps1 -WinAppSDKVersion 2.4.0
.\build.ps1 -Sample WindowsAIFoundry\cs-winui -Platform x64

Select an experimental package available in the configured NuGet feed to include the extensions:

.\UpdateVersions.ps1 -WinAppSDKVersion '<experimental-version>'
.\build.ps1 -Sample WindowsAIFoundry\cs-winui -Platform x64

See additional instructions for using the C++ and CMake sample.

Special Considerations for Unpackaged and Self-Contained modes with Windows AI APIs

  • Unpackaged app configuration is no longer supported. Every app using Windows AI APIs must have a package identity which can be granted to apps with an external location to achieve that with unpackaged binaries.
  • Self-contained mode is fully supported by Windows AI APIs as well.
  • The following command demonstrates how to run the app as an ARM64 application in packaged self-contained mode (for both WinAppSDK and .NET):
dotnet run -p:Configuration=Debug -p:Platform=ARM64 -p:WindowsAppSDKSelfContained=true -p:SelfContained=true.