微软软件包:-winget 是微软官方推出的 Windows 包管理器(Windows Package Manager) - DesktopAppInstaller_1
winget 是微软官方推出的 Windows 包管理器(Windows Package Manager),代号 “winget-cli”。一句话理解:“让 Windows 像 Linux apt/yum 一样,一行命令装、卸、更新软件。”
────────────────
诞生背景 • 2020 年 Build 大会公布,2021 随 Windows 11 内置,Win10 2004+ 通过 App Installer 更新获得。 • 解决痛点: – 官网找 EXE/MSI 麻烦; – 安装包带广告/捆绑; – 更新靠手动。
──────────────── 2. 核心概念
概念说明示例manifestYAML 清单文件,描述软件名、版本、下载地址、哈希Mozilla.Firefox源(source)清单仓库,默认微软官方 winget;可自建winget source add contoso https://包 id唯一标识符,通常是 Publisher.AppVideoLAN.VLC包版本manifest 中写死的版本号,可指定安装--version 3.0.18
──────────────── 3. 常用命令(Win+R → cmd / PowerShell / Terminal 直接输)
# 搜索
winget search vscode
# 安装(静默 + 阻止重启)
winget install Microsoft.VisualStudioCode --silent --accept-source-agreements
# 更新指定包
winget upgrade Mozilla.Firefox
# 更新所有
winget upgrade --all
# 卸载
winget uninstall 7zip.7zip
# 查看已装
winget list
# 导出/导入机器清单
winget export -o myapps.json
winget import myapps.json
──────────────── 4. 与 Chocolatey / Scoop 的区别
维度wingetChocolateyScoop官方背景微软官方社区社区包格式EXE/MSI/MSIX/ZipNuPkg便携压缩包权限部分需管理员管理员用户级生态数量5 k+10 k+6 k+默认安装位置原安装器决定ProgramData用户目录
──────────────── 5. 进阶玩法 • 自定义源:公司内网可放私有仓库(Git 静态站即可)。 • 脚本化装机:新机一键 winget import dev.json,20 秒装好开发环境。 • 与 Dev Home / WinGet Configuration 集成:YAML 描述整台机器环境(IDE、SDK、WSL 发行版)。
──────────────── 6. 一句话速记 “Windows 上想装软件 → 先 winget search,再 winget install 包ID --silent,爽到飞起。”
实践
到windows商店查找winget ,找到了Winget-AutoUpdate-aaS
powershell中安装
在powershell中安装
Set-ExecutionPolicy RemoteSigned Invoke-WebRequest -Uri "https://gitcode.com/gh_mirrors/wi/winget-install/raw/main/install.ps1" -OutFile "install.ps1"
.\install.ps1
安装失败
从官网下载安装
看官网:使用 WinGet 安装和管理应用程序 | Microsoft Learn
从这里下载:https://aka.ms/getwingetpreview
下载速度非常慢。(第二天早晨,下载速度恢复正常,不知道是不是cdn加速起作用了)
下载后安装,提示:
应该就是这个吧? 以前的是1.27.350.0版本,一会儿装好看看现在的版本。
安装完还没有winget命令
注册一下
Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe
还是不行。
解决问题
在window10的查找里面,输入winget,可以看到winget的图标
通过图标找到它所在的位置
C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.27.420.0_x64__8wekyb3d8bbwe
使用管理员权限打开一个cmd窗口,进入这个目录,这时候再输入winget,就能执行了:
C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.27.420.0_x64__8wekyb3d8bbwe>winget.exe
Windows Package Manager v1.12.420
The winget command line utility enables installing applications and other packages from the command line.
usage: winget [] []
The following commands are available:
install Installs the given package
show Shows information about a package
source Manage sources of packages
search Find and show basic info of packages
list Display installed packages
upgrade Shows and performs available upgrades
uninstall Uninstalls the given package
hash Helper to hash installer files
validate Validates a manifest file
settings Open settings or set administrator settings
features Shows the status of experimental features
export Exports a list of the installed packages
import Installs all the packages in a file
pin Manage package pins
configure Configures the system into a desired state
download Downloads the installer from a given package
repair Repairs the selected package
dscv3 DSC v3 resource commands
mcp MCP information
For more details on a specific command, pass it the help argument. [-?]
The following options are available:
-v,--version Display the version of the tool
--info Display general info of the tool
-?,--help Shows help about the selected command
--wait Prompts the user to press any key before exiting
--logs,--open-logs Open the default logs location
--verbose,--verbose-logs Enables verbose logging for winget
--nowarn,--ignore-warnings Suppresses warning outputs 拼多多帮助力入口
--disable-interactivity Disable interactive prompts
--proxy Set a proxy to use for this execution
--no-proxy Disable the use of proxy for this execution
More help can be found at: https://aka.ms/winget-command-help
C:\Program Files\WindowsApps\Microsoft.DesktopAppInstaller_1.27.420.0_x64__8wekyb3d8bbwe>winget search wget
Name Id Version Match Source
--------------------------------------------------
Wget JernejSimoncic.Wget 1.21.4 winget
Wget2 GNU.Wget2 2.1.0 Tag: wget winget
看,我们很容易找到了wget,再去找nginx试试
winget search nginx
Name Id Version Match Source
-----------------------------------------------------------------------------------
nginx freenginx.nginx 1.29.0 winget
nginx nginxinc.nginx 1.29.3 winget
Nginx UI 0xJacky.nginx-ui 2.2.1 Tag: nginx winget
Laragon LeNgocKhoa.Laragon 8.3.0 Tag: nginx winget
MAMP & MAMP PRO MAMP.MAMP 5.0.5 Tag: nginx winget
nginx-prometheus-exporter nginx.nginx-prometheus-exporter 1.5.0 winget
真不错,windows早该这样啦!
总结:
现在我卡在安装这里,真的很无语。(昨天)
我感觉微软把这个工具的使用难度(仅仅是安装难度)给搞到天际了,我已经十多年不怎么吐槽微软了...
下载速度爆慢...(不过今天早晨,速度就起来了!下载速度正常了)
总之是个好东西,以后多多用!
调试
运行报错winget search vscode
winget search vscode 'winget' is not recognized as an internal or external command, operable program or batch file.
Add-AppxPackage -RegisterByFamilyName -MainPackage 注册失败
Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopAppInstaller_8wekyb3d8bbwe
Add-AppxPackage : Deployment failed with HRESULT: 0x80073D02, The package could not be installed because resources it
modifies are currently in use.
error 0x80073D02: Unable to install because the following apps need to be closed
Microsoft.DesktopAppInstaller_1.27.350.0_x64__8wekyb3d8bbwe.
NOTE: For additional information, look for [ActivityId] de7cbf54-5c6e-0016-5c48-a9de6e5cdc01 in the Event Log or use
the command line Get-AppPackageLog -ActivityID de7cbf54-5c6e-0016-5c48-a9de6e5cdc01
At line:1 char:1
+ Add-AppxPackage -RegisterByFamilyName -MainPackage Microsoft.DesktopA ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Microsoft.Deskt...r_8wekyb3d8bbwe:String) [Add-AppxPackage], Exception
+ FullyQualifiedErrorId : DeploymentError,Microsoft.Windows.Appx.PackageManager.Commands.AddAppxPackageCommand
是因为没有装winget,所以在powershell下注册失败。先去下载安装包,安装完再注册。