Edit

Install and deploy Windows ML

Windows ML supports two deployment modes for the Windows ML Runtime: self-contained and framework-dependent. Choose based on your app's size, update, and dependency requirements.

To learn more about Windows ML, see What is Windows ML.

Quick start

Here's the short version of how to install Windows ML in your project:

For self-contained (increases app size by ~41 MB, doesn't auto-update):

For framework-dependent (smaller app size, auto-updates), install:

For full details on each option, see the sections below.

Requirements

Note

With .NET 6, you can use the Microsoft.Windows.AI.MachineLearning namespace to install execution providers, but Microsoft.ML.OnnxRuntime APIs are not available. Upgrade to .NET 8 to access the full Windows ML API surface.

What's in the Windows ML Runtime

The Windows ML Runtime is composed of these binaries:

Binary Description Approx. size
Microsoft.Windows.AI.MachineLearning.dll Windows ML APIs (ExecutionProviderCatalog, etc.) ~1 MB
onnxruntime.dll The ONNX Runtime engine ~20 MB
DirectML.dll DirectML — the included GPU execution provider ~20 MB
Total ~41 MB

Vendor execution providers (QNN, VitisAI, OpenVINO, NvTensorRtRtx, MIGraphX) are not part of the Windows ML Runtime. They are obtained separately — either via the ExecutionProviderCatalog at runtime, or bundled yourself. See Accelerate AI models.

Choosing a deployment mode

When using Windows ML, you can choose between two deployment modes for the Windows ML Runtime: self-contained and framework-dependent.

Self-contained Framework-dependent
Supported languages C#, C++/WinRT, C/C++ C#, C++/WinRT, Python
Supported packaging types Unpackaged and packaged (MSIX) Unpackaged and packaged (MSIX)
Enterprise deployment Supported Supported
App size Larger — Windows ML Runtime binaries are bundled with your app (~41 MB) Smaller — Windows ML Runtime binaries are shared system-wide
Windows ML updates Manual — you ship a new version when you choose Automatic — users get updates via Windows App SDK servicing
Dependency on installed runtime No — all dependencies are in your app package Yes — Windows App SDK runtime must be present
NuGet package (C#/C++) Microsoft.Windows.AI.MachineLearning or Microsoft.WindowsAppSDK.ML Microsoft.WindowsAppSDK.ML + Microsoft.WindowsAppSDK.Runtime
Best for Strict version control Apps that require a minimal download/install size; Apps shipping through the Microsoft Store

Self-contained installation

Apps can choose to self-contain the Windows ML Runtime binaries directly in the app. No external runtime dependency is required, but your app will be larger. This is the default when you reference Microsoft.Windows.AI.MachineLearning or Microsoft.WindowsAppSDK.ML without referencing the main Microsoft.WindowsAppSDK or Microsoft.WindowsAppSDK.Runtime package. If you're using the Windows App SDK packages, see Deployment guide for self-contained apps for details.

In your project, install or update the following NuGet packages:

  • For apps targeting Windows 10 Build 18362 or higher:
  • Or, for apps targeting Windows 10 Build 17763 or higher:
    • Install Microsoft.WindowsAppSDK.ML (this adds the Windows ML APIs and binaries, defaults to self-contained, and adds RegFree WinRT support for 17763)
  • Do NOT install Microsoft.WindowsAppSDK.Runtime (this would enable framework-dependent mode... remove it if you currently have it installed)
  • Do NOT install the main Microsoft.WindowsAppSDK NuGet package (this would enable framework-dependent mode... remove it if you currently have it installed)
  • Feel free to install other Windows App SDK component packages like Microsoft.WindowsAppSDK.AI, as long as you don't install the Runtime or the main package

Note

If you must use the main Microsoft.WindowsAppSDK NuGet package, update it to version 1.8.1 or greater, which includes Windows ML and all other Windows App SDK APIs, and in your .csproj, set WindowsAppSDKSelfContained to true to enable self-contained mode.

Framework-dependent installation

The framework-dependent version of the Windows ML Runtime is contained in the Windows App SDK runtime, which must be installed on the end user's machine. See Deployment for Windows App SDK framework-dependent apps for details.

In your project, install or update the following NuGet packages:

Note

Alternatively, install / update the main Microsoft.WindowsAppSDK NuGet package to version 1.8.1 or greater, which includes Windows ML and all other Windows App SDK APIs, and defaults to framework-dependent.

Also, in your .csproj file, ensure that WindowsAppSDKSelfContained is either unspecified (not present), or false, so that it uses framework-dependent deployment.

Finally, see Deployment architecture for framework-dependent apps to learn how to deploy the Windows App SDK runtime to your user's devices alongside your app.

Next step

See also