MSIX Manager Sample

A practical example for managing MSIX packages with Windows app development tools.

Understanding the MSIX Manager Sample

This sample demonstrates how to programmatically interact with MSIX packages on Windows using the MSIX Packaging API. It provides a foundation for building custom tools to manage application installations, updates, and uninstalls, offering greater control and automation capabilities for developers and IT professionals.

MSIX Manager Conceptual Diagram

Key Features Showcased

Setup and Prerequisites

To run this sample, ensure you have the following:

Clone the repository from the official Microsoft GitHub or download the source code directly.

Usage Guide

The sample application provides a simple command-line interface (CLI) or a basic GUI (depending on the implementation) to perform the following operations:

  1. List Packages: Executes a command to display all MSIX packages installed on the system.
  2. Install Package: Prompts for the path to an MSIX file and initiates the installation.
  3. Update Package: Prompts for the path to an MSIX update file and applies it to the existing installation.
  4. Uninstall Package: Prompts for the package name or family name and removes it.
Important: Running package management operations often requires administrator privileges. Ensure your application is run with elevated permissions when performing installations or uninstalls.

Core Code Snippet (Conceptual C#)

Here’s a glimpse into the core logic for uninstalling a package. The full sample provides more comprehensive examples for all operations.


using Microsoft.WindowsAppRuntime.Packaging;
using System;
using System.Linq;

public class MsixPackageManager
{
    public void UninstallPackage(string packageFamilyName)
    {
        try
        {
            var package = MsixPackageManager.Current.FindPackagesForCurrentUser().FirstOrDefault(p => p.PackageFamilyName == packageFamilyName);

            if (package != null)
            {
                Console.WriteLine($"Uninstalling package: {package.PackageFullName}...");
                MsixPackageManager.Current.RemovePackage(package.PackageFullName);
                Console.WriteLine("Package uninstalled successfully.");
            }
            else
            {
                Console.WriteLine($"Package '{packageFamilyName}' not found for the current user.");
            }
        }
        catch (Exception ex)
        {
            Console.WriteLine($"Error uninstalling package: {ex.Message}");
        }
    }

    // Add methods for InstallPackage, UpdatePackage, FindPackages, etc.
}
            

Advanced Topics

Explore further by integrating MSIX management into your CI/CD pipelines, handling different deployment targets (e.g., enterprise deployments), or managing application updates through a custom catalog.

Troubleshooting Common Issues