winget install: Windows Package Manager in CI
winget install adds a package from the Windows Package Manager; for CI you pass --silent plus the two --accept agreement flags so it never blocks on a prompt.
winget is Microsoft's built-in package manager. It is reliable on interactive Windows but needs explicit agreement and silent flags to behave unattended in a pipeline.
What it does
winget install resolves a package by name or id and runs its installer. By default it can prompt to accept a package or source license agreement; CI must pre-accept both. Use -e --id to match an exact package id and avoid ambiguous-name failures.
Common usage
winget install -e --id Git.Git \
--silent \
--accept-package-agreements \
--accept-source-agreements
# pin a version
winget install -e --id Microsoft.PowerShell --version 7.4.1 \
--silent --accept-package-agreements --accept-source-agreementsOptions
| Flag | What it does |
|---|---|
| -e, --exact | Match the id/name exactly (no fuzzy match) |
| --id <id> | Select the package by its winget id |
| --silent / -h | Run the installer with no UI |
| --accept-package-agreements | Pre-accept the package license |
| --accept-source-agreements | Pre-accept the source (msstore) terms |
| --version <v> | Install a specific version |
In CI
winget is not always available on hosted runners or in non-interactive Windows Server sessions because it ships with the App Installer; verify it exists or fall back to choco. Always pass -e --id; a bare name can match multiple packages and fail.
Common errors in CI
"No package found matching input criteria" means the id is wrong or -e rejected a fuzzy match; check winget search. The installer hanging usually means a missing --silent or one of the --accept-* flags, so winget waited on a prompt. "winget is not recognized" means App Installer is absent (common in containers and Server Core); install it or use another package manager.