160 lines
3.0 KiB
Markdown
160 lines
3.0 KiB
Markdown
# Winget Quick Reference
|
|
|
|
Windows Package Manager (`winget`) is Microsoft's CLI tool for installing, updating, and managing software.
|
|
|
|
---
|
|
|
|
## Search for Packages
|
|
|
|
```powershell
|
|
# Search by name
|
|
winget search vscode
|
|
|
|
# Web-based search UI
|
|
# https://solrevdev.com/winget-search/
|
|
```
|
|
|
|
---
|
|
|
|
## Install
|
|
|
|
```powershell
|
|
# Basic install
|
|
winget install <package-name>
|
|
|
|
# Install with exact ID match (-e = --exact)
|
|
winget install -e --id Microsoft.VisualStudioCode
|
|
|
|
# Install specific version
|
|
winget install -e --id Oven-sh.Bun --version 1.1.0
|
|
|
|
# Accept all agreements automatically (useful for scripts)
|
|
winget install -e --id Oven-sh.Bun --accept-package-agreements --accept-source-agreements
|
|
```
|
|
|
|
### Installation Scope
|
|
|
|
```powershell
|
|
# Install for current user only (no admin required)
|
|
winget install -e --id Oven-sh.Bun --scope user
|
|
|
|
# Install system-wide (requires admin)
|
|
winget install -e --id Oven-sh.Bun --scope machine
|
|
```
|
|
|
|
---
|
|
|
|
## Uninstall
|
|
|
|
```powershell
|
|
# Basic uninstall
|
|
winget uninstall <package-name>
|
|
|
|
# Uninstall with exact ID
|
|
winget uninstall -e --id Oven-sh.Bun
|
|
|
|
# Uninstall and remove app data (if supported)
|
|
winget uninstall -e --id Oven-sh.Bun --purge
|
|
```
|
|
|
|
---
|
|
|
|
## Update / Upgrade
|
|
|
|
```powershell
|
|
# List packages with available updates
|
|
winget upgrade
|
|
|
|
# Update a specific package
|
|
winget upgrade -e --id Oven-sh.Bun
|
|
|
|
# Update ALL packages
|
|
winget upgrade --all
|
|
|
|
# Update all, accepting agreements (for scripts)
|
|
winget upgrade --all --accept-package-agreements --accept-source-agreements
|
|
```
|
|
|
|
---
|
|
|
|
## View Package Info
|
|
|
|
```powershell
|
|
# Show package details (version, publisher, license, install URL)
|
|
winget show Oven-sh.Bun
|
|
|
|
# Show all available versions
|
|
winget show Oven-sh.Bun --versions
|
|
```
|
|
|
|
---
|
|
|
|
## List Installed Packages
|
|
|
|
```powershell
|
|
# List all installed packages (from all sources)
|
|
winget list
|
|
|
|
# Filter by name
|
|
winget list bun
|
|
```
|
|
|
|
---
|
|
|
|
## Export / Import (Lockfile-like System)
|
|
|
|
Export your installed packages to a JSON file for reproducible setups:
|
|
|
|
```powershell
|
|
# Export all packages
|
|
winget export -o winget-pkgs.json
|
|
|
|
# Export with pinned versions
|
|
winget export -o winget-pkgs-lock.json --include-versions
|
|
```
|
|
|
|
Import on a new machine:
|
|
|
|
```powershell
|
|
# Install all packages from export file
|
|
winget import -i winget-pkgs-lock.json --accept-package-agreements --accept-source-agreements
|
|
```
|
|
|
|
---
|
|
|
|
## Common Flags Reference
|
|
|
|
| Flag | Long Form | Description |
|
|
|------|-----------|-------------|
|
|
| `-e` | `--exact` | Match package ID exactly |
|
|
| `-h` | `--silent` | Silent install (no UI) |
|
|
| `-i` | `--interactive` | Interactive install (show installer UI) |
|
|
| `-o` | `--output` | Output file path |
|
|
| `-v` | `--version` | Specify version |
|
|
| | `--scope` | `user` or `machine` |
|
|
| | `--accept-package-agreements` | Auto-accept package license |
|
|
| | `--accept-source-agreements` | Auto-accept source agreements |
|
|
|
|
---
|
|
|
|
## Settings
|
|
|
|
Open winget settings file:
|
|
|
|
```powershell
|
|
winget settings
|
|
```
|
|
|
|
Example settings (JSON):
|
|
|
|
```json
|
|
{
|
|
"installBehavior": {
|
|
"preferences": {
|
|
"scope": "user"
|
|
}
|
|
}
|
|
}
|
|
```
|
|
|