![]() |
VOOZH | about |
dotnet add package Microsoft.WindowsAppSDK.ML --version 2.1.70
NuGet\Install-Package Microsoft.WindowsAppSDK.ML -Version 2.1.70
<PackageReference Include="Microsoft.WindowsAppSDK.ML" Version="2.1.70" />
<PackageVersion Include="Microsoft.WindowsAppSDK.ML" Version="2.1.70" />Directory.Packages.props
<PackageReference Include="Microsoft.WindowsAppSDK.ML" />Project file
paket add Microsoft.WindowsAppSDK.ML --version 2.1.70
#r "nuget: Microsoft.WindowsAppSDK.ML, 2.1.70"
#:package Microsoft.WindowsAppSDK.ML@2.1.70
#addin nuget:?package=Microsoft.WindowsAppSDK.ML&version=2.1.70Install as a Cake Addin
#tool nuget:?package=Microsoft.WindowsAppSDK.ML&version=2.1.70Install as a Cake Tool
The Microsoft.WindowsAppSDK.ML package brings Windows ML to your project as part of the Windows
App SDK. To use it correctly, follow these steps:
Windows ML is recommended to be used as a framework-dependent component. This means your app should either:
Microsoft.WindowsAppSDK (recommended). This will automatically include
Microsoft.WindowsAppSDK.ML as a transitive dependency.Microsoft.WindowsAppSDK.ML and
Microsoft.WindowsAppSDK.Runtime.Note: If you only reference
Microsoft.WindowsAppSDK.MLwithoutMicrosoft.WindowsAppSDK.Runtime, your app will not deploy or run correctly.
For applications that need to bundle ONNX Runtime dependencies locally without relying on framework packages, enable self-contained mode:
<PropertyGroup>
<WindowsAppSDKSelfContained>true</WindowsAppSDKSelfContained>
</PropertyGroup>
Tip: If ONNX Runtime binaries are not being copied to your output directory correctly, ensure you have an explicit reference to
Microsoft.WindowsAppSDK.Basein your project, as this package contains the necessary build targets for binary deployment.
In self-contained mode, ONNX Runtime binaries are deployed alongside your application:
MyApp/
├── MyApp.exe
├── Microsoft.Windows.AI.MachineLearning.dll
├── onnxruntime.dll
└── DirectML.dll
This mode is useful for:
If your app is unpackaged (not MSIX), add the following property to your project to enable the Windows App SDK bootstrapper:
<WindowsPackageType>None</WindowsPackageType>
This is a temporary requirement and will be auto-detected in future releases.
Windows ML supports enumerating available execution providers through the PackageExtensionCatalog API. However, this functionality has specific requirements and limitations:
For execution provider enumeration to work in packaged applications, your app manifest must declare the packageQuery capability:
<Package>
<Capabilities>
<uap4:Capability Name="packageQuery" />
</Capabilities>
</Package>
packageQuery capability is not declared in the app manifestFor unpackaged applications running in AppContainer mode, the packageQuery capability must be granted to the process token when creating the AppContainer. This is done by including the capability SID in the AppContainer creation:
// When creating an AppContainer for an unpackaged process
PSID packageQuerySid = nullptr;
ConvertStringSidToSid(L"S-1-15-3-1024-1962849891-688487262-3571417821-3628679630-802580238-1922556387-206211640-3335523193", &packageQuerySid);
SID_AND_ATTRIBUTES capabilities[] = {
{ packageQuerySid, SE_GROUP_ENABLED }
};
// Include the capabilities when creating the AppContainer token
// This allows the unpackaged AppContainer process to use PackageExtensionCatalog APIs
The SID S-1-15-3-1024-1962849891-688487262-3571417821-3628679630-802580238-1922556387-206211640-3335523193 corresponds to the packageQuery capability.
When execution provider enumeration is not available or returns empty results, Windows ML will gracefully fall back to using built-in providers, e.g. the CPU execution provider.
For applications that require specific execution providers, consider brokering and explicitly configuring them rather than relying on automatic enumeration.
The ONNX Runtime headers are included in a winml subdirectory to avoid conflicts with other versions of ONNX Runtime. When using these headers in your code, include them with the subdirectory prefix:
#include <winml/onnxruntime_c_api.h>
#include <winml/onnxruntime_cxx_api.h>
If your existing code uses the headers without the winml/ prefix and you cannot update your includes, you can enable this behavior by setting the WinMLEnableDefaultOrtHeaderIncludePath property in your project:
<PropertyGroup>
<WinMLEnableDefaultOrtHeaderIncludePath>true</WinMLEnableDefaultOrtHeaderIncludePath>
</PropertyGroup>
For redistributed components that are consumed by other applications where ONNX Runtime initialization is handled externally, enable passthrough mode:
<PropertyGroup>
<WindowsAppSDKMLPassthroughOnnxRuntime>true</WindowsAppSDKMLPassthroughOnnxRuntime>
</PropertyGroup>
Passthrough mode is designed for scenarios where:
In passthrough mode, Windows ML assumes ONNX Runtime (onnxruntime.dll) is already loaded in the current process and uses GetModuleHandle to access the already-loaded library instead of attempting its own initialization or dependency resolution.
The Microsoft.WindowsAppSDK.ML NuGet package can be referenced without a Windows App SDK
dependency (Microsoft.WindowsAppSDK or Microsoft.WindowsAppSDK.Foundation). No additional
configuration is required — simply reference Microsoft.WindowsAppSDK.ML on its own.
When used without Windows App SDK, ONNX Runtime headers are available with the winml/ prefix
— use #include <winml/onnxruntime_cxx_api.h>. To use headers without the prefix, set
WinMLEnableDefaultOrtHeaderIncludePath to true in your project (see
Using ONNX Runtime headers without a prefix).
When no Windows App SDK is present, the build targets link onnxruntime.lib and
Microsoft.Windows.AI.MachineLearning.lib directly into the consuming binary. This means the OS
loader resolves onnxruntime.dll and Microsoft.Windows.AI.MachineLearning.dll at process start using the
standard Windows DLL search order,
rather than loading it dynamically at runtime. Runtime DLLs (onnxruntime.dll, DirectML.dll,
Microsoft.Windows.AI.MachineLearning.dll) are automatically copied from the NuGet package to the
output directory at build time when using MSBuild with NuGet targets. For non-MSBuild builds, such
as custom or native setups, this automatic copy behavior may not apply.
The C API (WinMLEpCatalog.h, etc.) is also available and provides direct function exports without
requiring WinRT class registration.
This is designed for:
The package implements automatic ONNX Runtime initialization through a custom OrtGetApiBase
implementation. This takes care of the initialization details and provides transparent access to the
ONNX Runtime binaries shipping with Windows ML without requiring developers to link against
onnxruntime.lib. See include\WindowsMLAutoInitializer.cpp.
For applications requiring explicit control over initialization sequences or those not utilizing ONNX Runtime APIs, auto-initialization can be disabled via MSBuild property:
<PropertyGroup>
<DisableWindowsAppSDKMLAutoInitialize>true</DisableWindowsAppSDKMLAutoInitialize>
</PropertyGroup>
For advanced C++ applications where the auto-initializer pattern is not feasible and you need to directly link against the ONNX Runtime import library, you can enable native linking:
<PropertyGroup>
<WindowsMLNativeLinkOnnxRuntime>true</WindowsMLNativeLinkOnnxRuntime>
</PropertyGroup>
⚠️ Important: This is an edge-case scenario for advanced users. Most applications should use the standard auto-initialization approach described above.
When WindowsMLNativeLinkOnnxRuntime is set to true:
DisableWindowsAppSDKMLAutoInitializeonnxruntime.lib for your target platform (x64, ARM64, ARM64EC)#include <winml/onnxruntime_c_api.h> or #include <winml/onnxruntime_cxx_api.h>The consuming binary must ensure the correct onnxruntime.dll is available in the proper search order:
Failure to meet these requirements will result in runtime linking errors or incompatible DLL loading.
This mode is only recommended for:
Build your project as usual. The Windows ML APIs will be available for use.
Samples directory or visit
WindowsAppSDK-Samples.| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| native | native native is compatible. |
Showing the top 2 NuGet packages that depend on Microsoft.WindowsAppSDK.ML:
| Package | Downloads |
|---|---|
|
Microsoft.WindowsAppSDK
The Windows App SDK empowers all Windows Desktop apps with modern Windows UI, APIs, and platform features, including back-compat support. |
|
|
Microsoft.ML.OnnxRuntimeGenAI.WinML
ONNX Runtime Generative AI Native Package |
Showing the top 1 popular GitHub repositories that depend on Microsoft.WindowsAppSDK.ML:
| Repository | Stars |
|---|---|
|
hpavlo/Rememory
Rememory | Clipboard Manager
|
| Version | Downloads | Last Updated |
|---|---|---|
| 2.1.75-experimental | 560 | 6/9/2026 |
| 2.1.70 | 15,401 | 6/9/2026 |
| 2.1.3-experimental | 1,354 | 5/21/2026 |
| 2.1.1 | 55,251 | 5/21/2026 |
| 2.0.325-experimental | 1,716 | 4/21/2026 |
| 2.0.300 | 66,810 | 4/29/2026 |
| 2.0.297-preview | 1,920 | 3/31/2026 |
| 2.0.255-experimental | 2,398 | 3/13/2026 |
| 2.0.175-preview | 5,833 | 2/13/2026 |
| 2.0.171-experimental | 844 | 2/13/2026 |
| 2.0.169-experimental | 2,262 | 1/13/2026 |
| 2.0.44-experimental | 35,562 | 11/11/2025 |
| 2.0.36-experimental | 1,306 | 11/6/2025 |
| 1.8.2197 | 13,506 | 5/12/2026 |
| 1.8.2192 | 30,369 | 4/21/2026 |
| 1.8.2141 | 87,152 | 3/18/2026 |
| 1.8.2124 | 122,530 | 2/10/2026 |
| 1.8.2119 | 157,083 | 1/13/2026 |
| 1.8.2109 | 315,017 | 11/11/2025 |
| 1.8.2095 | 58,084 | 10/14/2025 |