{ claus.conrad }

Explore the Windows Package Manager tool

https://learn.microsoft.com/en-us/training/modules/explore-windows-package-manager-tool/

Introduction

  • [winget](…/Windows Package Manager/) is an [open source](…/open source/) tool to install/uninstall software from the [Windows](…/Microsoft Windows/) command line
  • Targeting B2C and B2B
  • Supports [Windows](…/Microsoft Windows/) 10, 11, and Server

Explain the purpose of Windows Package Manager

  • A package represents an application
  • A manifest is a (set of) metadata file(s) that instruct [winget](…/Windows Package Manager/) on how to (un)install a package
  • A source is a repository containing manifests
  • Sources that are enabled by default (but can be disabled through group policy):
    • msstore - apps (without age restriction) from the Microsoft Store
    • winget - a community repository curated by volunteers and secured by Microsoft (similar to the AUR for [Arch Linux](…/Arch Linux/))
  • Organizations can host their own sources, which are based on a REST API

Install and uninstall software with Windows Package Manager

  • Search for a package:
    winget search SEARCH_TERM
    
  • Install a package:
    winget install PACKAGE_ID
    
  • CLI flags can be used to install from a local manifest, force installation by ID only, only search the name, specify a specific version to install, install quietly, and more.
  • Uninstall a package:
    winget uninstall PACKAGE_ID
    

Update software with Windows Package Manager

  • List available updates:
    winget upgrade
    
  • Upgrade one package:
    winget upgrade PACKAGE_ID
    
  • Upgrade all packages with updates:
    winget upgrade --all
    

Discuss the Windows Package Manager repository

  • The Windows Package Manager Community Repository is a source that everyone can contribute to.
  • Manifests are in YAML format.
  • A source has the following directory structure: manifests / m / Microsoft / PowerShell / 7.1.4.0 Where:
    • manifests is always the same static name for the top level directory
    • m is the lower-cased first letter of the publisher name
    • Microsoft is the publisher
    • PowerShell is the application
    • 7.1.4.0 is the version
  • The publisher, application and version directories each store relevant metadata.

Contribute to the Windows Package Manager repository

  • Requirements for contributing packages:
    • A GitHub account
    • The installer needs to be in MSIX, MSI or EXE format
    • Not a duplicate
  • microsoft/winget-create - Windows Package Manager Manifest Creator CLI
    • Create a new package:
      wingetcreate new INSTALLER_URL_1 INSTALLER_URL_2 ...
      
      • Only one URL is required, but there could be multiple, e.g. for different architectures (x64 vs. arm64, etc.)
    • The schema supports “singleton” manifests (all metadata in one file), but wingetcreate creates multi-file manifests, and those are the only ones accepted by the community repository
  • The PACKAGE_ID.installer.yaml supports specifying InstallerSwitches, e.g. for silent installation
  • Packages can be “tagged” to be discoverable using miscellaneous search terms
  • Validate a manifest:
    winget validate -manifest MANIFEST_PATH
    
  • Test-install a manifest:
    winget install -manifest MANIFEST_PATH
    
  • “[Windows](…/Microsoft Windows/) Sandbox” is a disposable [VM](…/Virtual Machine/) in [Windows](…/Microsoft Windows/) 11 Pro and higher editions that can simplify testing installers
  • Store a GitHub token to allow wingetcreate to open pull requests for package contributions:
    wingetcreate -store GITHUB_PAT_TOKEN
    
  • Open a pull request from wingetcreate (this automatically forks the community repository in the user’s GitHub account):
    wingetcreate submit MANIFEST_PATH
    

Host your own Windows Package Manager repository

  • microsoft/winget-cli-restsource - a reference implementation of a REST based package source for the winget client
  • Use group policy to configure installer source repositories available to enterprise users

Control Windows Package Manager with Group Policy

  • A group policy template in the ADMX/ADML format can be downloaded here.
  • Users can see the applied policies using:
    winget --info
    
  • Using group policy, enterprise administrators can configure:
    • Whether Windows Package Manager is enabled
    • If users may change their settings
    • Whether hashes can be overridden
    • The ability to enable experimental features
    • Local manifest installation
    • The auto update interval for sources
    • The default source (the community repository)
    • The Microsoft Store source
    • Whether users can add sources
    • Which sources users can enable/disable, if any

Summary

Resources