Skip to main content

Introduction

The Windows Package Manager COM API provides programmatic access to WinGet functionality through two primary namespaces:
  • Microsoft.Management.Deployment - Package installation, uninstallation, and catalog management
  • Microsoft.Management.Configuration - Configuration set processing and system state management
These COM APIs enable developers to integrate WinGet capabilities into their applications using C#, C++, or any COM-compatible language.

Key Features

Package Management

  • Install, Upgrade, Uninstall - Manage packages programmatically
  • Search and Discovery - Find packages across multiple catalogs
  • Catalog Management - Add, remove, and configure package sources
  • Progress Tracking - Monitor installation progress with detailed callbacks
  • Authentication - Support for Microsoft Entra ID authentication

Configuration Management

  • Declarative Configuration - Define system state using YAML configuration sets
  • Test, Get, Set Operations - Test current state, retrieve settings, and apply configurations
  • Dependency Management - Handle configuration unit dependencies
  • Progress Events - Track configuration application progress
  • Conflict Detection - Identify conflicts between configuration sets

Architecture

Microsoft.Management.Deployment

Microsoft.Management.Configuration

Common Use Cases

Package Installation

using Microsoft.Management.Deployment;

// Create PackageManager
var manager = new PackageManager();

// Get catalog and search for package
var catalog = manager.GetPackageCatalogByName("winget");
var connectResult = await catalog.ConnectAsync();

var options = new FindPackagesOptions();
options.Selectors.Add(new PackageMatchFilter() 
{
    Field = PackageMatchField.Id,
    Value = "Microsoft.PowerToys",
    Option = PackageFieldMatchOption.Equals
});

var result = await connectResult.PackageCatalog.FindPackagesAsync(options);
if (result.Matches.Count > 0)
{
    var package = result.Matches[0].CatalogPackage;
    var installOptions = new InstallOptions();
    var installResult = await manager.InstallPackageAsync(package, installOptions);
}

Configuration Application

using Microsoft.Management.Configuration;

// Create configuration processor
var factory = await ConfigurationStaticFunctions.CreateConfigurationSetProcessorFactoryAsync("pwsh");
var processor = new ConfigurationProcessor(factory);

// Open configuration file
var file = await StorageFile.GetFileFromPathAsync("config.yml");
var stream = await file.OpenReadAsync();
var openResult = await processor.OpenConfigurationSetAsync(stream);

if (openResult.Set != null)
{
    // Apply configuration
    var applyResult = await processor.ApplySetAsync(
        openResult.Set, 
        ApplyConfigurationSetFlags.None
    );
}

Language Support

C#

Use with .NET applications by adding the Windows SDK projection:
<ItemGroup>
  <PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.22621.2" />
</ItemGroup>

C++

Use with C++/WinRT:
#include <winrt/Microsoft.Management.Deployment.h>
#include <winrt/Microsoft.Management.Configuration.h>

using namespace winrt::Microsoft::Management::Deployment;
using namespace winrt::Microsoft::Management::Configuration;

Error Handling

All COM API operations return result objects with:
  • Status Enums - High-level operation status
  • HRESULT Codes - Detailed error codes
  • Extended Information - Result descriptions and details
See Error Handling for comprehensive guidance.

Next Steps

Getting Started

Set up your development environment and create your first application

PackageManager

Learn about package installation and management

Configuration

Work with configuration sets and system state

Events & Progress

Track progress and handle events

API Contract Versions

  • Microsoft.Management.Deployment: Contract version 29 (WinGet 1.29+)
  • Microsoft.Management.Configuration: Contract version 4
Always check contract version requirements when using newer APIs.

Build docs developers (and LLMs) love