WinGet
介紹
Winget 是由 Microsoft 發佈的Windows 包管理器,它由兩部分組成:
- WinGet 命令行
- WinGet 服務
對於大多數 Windows 用戶, WinGet 是一個在 Windows 上管理應用程式(安裝、卸載、更新)的命令行工具。
先決條件
Item | Requirement |
---|---|
Windows | Windows 10 1709 以上(Windows 10.0.16299 以上) |
Microsoft.VCLibs.x64.14.00.Desktop | 需要被安裝 |
Microsoft.UI.Xaml | 需要被安裝 |
Microsoft.DesktopAppInstaller | 需要被安裝 |
以下是 WinGet 依賴的安裝命令:
Invoke-WebRequest -Uri https://aka.ms/getwinget -OutFile Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
Invoke-WebRequest -Uri https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx -OutFile Microsoft.VCLibs.x64.14.00.Desktop.appx
Invoke-WebRequest -Uri https://github.com/microsoft/microsoft-ui-xaml/releases/download/v2.8.6/Microsoft.UI.Xaml.2.8.x64.appx -OutFile Microsoft.UI.Xaml.2.8.x64.appx
Add-AppxPackage Microsoft.VCLibs.x64.14.00.Desktop.appx
Add-AppxPackage Microsoft.UI.Xaml.2.8.x64.appx
Add-AppxPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle
源
WinGet 的下載、安裝、更新的聯網操作都經過了 WinGet 源,通過 WinGet 獲取應用程式必須提供源。
WinGet 在安裝後默認提供兩個源:
- winget 源
- msstore 源
查詢源
winget source list
刪除源
winget source remove 源名稱
以刪除msstore
源爲例:
winget source remove msstore
重置源
winget source reset --force
搜索源上的應用程式
winget search 應用程式名稱
以搜索Terminal
爲例:
winget search terminal
這段命令將從 WinGet 源上搜索帶有 terminal 關鍵字的所有應用程式。
附帶-s winget
選項以搜索來自 winget 源的應用程式:
winget search terminal -s winget
安裝源上的應用程式
winget install 應用程式名稱
以terminal
爲例:
winget install Microsoft.WindowsTerminal
附帶-s msstore
以指定下載 msstore 源的應用程式。
winget install Microsoft.WindowsTerminal -s msstore
通過 WinGet 的-s msstore
選項,可實現在未安裝 Microsoft Store 的情況下獲取 Microsoft Store 源提供的應用程式的需求,這在使用非消費者版本 Windows 時很有用。
卸載應用程式
winget uninstall 應用程式名稱
以卸載terminal
爲例:
winget uninstall terminal
更新應用程式
若要檢測是否有應用程式需要更新:
winget upgrade
若要更新指定的應用程式:
winget upgrade 應用程式名稱
以更新terminal
爲例:
winget upgrade terminal
關於 MS 源的應用程式 ID 的查詢
MS 源的應用程式 ID 的方式:
- Microsoft Apps網站查詢
winget search 應用程式名稱 -s msstore
命令查詢
以terminal
爲例,在 Microsoft Apps 上,terminal
的搜索結果的地址爲:
https://apps.microsoft.com/detail/9n0dx20hk701
從地址中可以知道唯一標誌碼爲:
9n0dx20hk701
則安裝msstore
源上的Terminal
的命令行命令爲:
winget install 9n0dx20hk701 -s msstore