winget 是微软官方推出的 Windows 包管理器(Windows Package Manager)

winget 是微软官方推出的 Windows 包管理器(Windows Package Manager) ,代号 "winget-cli"。一句话理解:"让 Windows 像 Linux apt/yum 一样,一行命令装、卸、更新软件。"

────────────────

  1. 诞生背景
    • 2020 年 Build 大会公布,2021 随 Windows 11 内置,Win10 2004+ 通过 App Installer 更新获得。
    • 解决痛点:
    -- 官网找 EXE/MSI 麻烦;
    -- 安装包带广告/捆绑;
    -- 更新靠手动。

────────────────

  1. 核心概念
概念 说明 示例
manifest YAML 清单文件,描述软件名、版本、下载地址、哈希 Mozilla.Firefox
源(source) 清单仓库,默认微软官方 winget;可自建 winget source add contoso https://
包 id 唯一标识符,通常是 Publisher.App VideoLAN.VLC
包版本 manifest 中写死的版本号,可指定安装 --version 3.0.18

────────────────

  1. 常用命令(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

────────────────

  1. 与 Chocolatey / Scoop 的区别
维度 winget Chocolatey Scoop
官方背景 微软官方 社区 社区
包格式 EXE/MSI/MSIX/Zip NuPkg 便携压缩包
权限 部分需管理员 管理员 用户级
生态数量 5 k+ 10 k+ 6 k+
默认安装位置 原安装器决定 ProgramData 用户目录

────────────────

  1. 进阶玩法

自定义源 :公司内网可放私有仓库(Git 静态站即可)。

脚本化装机 :新机一键 winget import dev.json,20 秒装好开发环境。

与 Dev Home / WinGet Configuration 集成:YAML 描述整台机器环境(IDE、SDK、WSL 发行版)。

────────────────

  1. 一句话速记

"Windows 上想装软件 → 先 winget search,再 winget install 包ID --silent,爽到飞起。"

实践

到windows商店查找winget ,找到了Winget-AutoUpdate-aaS

安装

在中安装

复制代码
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

下载速度非常慢。

总结:

现在我卡在安装这里,真的很无语。

我感觉微软把这个工具的使用难度(仅仅是安装难度)给搞到天际了,我已经十多年不怎么吐槽微软了...

下载速度爆慢...

调试

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
相关推荐
lucky67072 小时前
Windows 上彻底卸载 Node.js
windows·node.js
编程小白20262 小时前
从 C++ 基础到效率翻倍:Qt 开发环境搭建与Windows 神级快捷键指南
开发语言·c++·windows·qt·学习
山岚的运维笔记3 小时前
SQL Server笔记 -- 第20章:TRY/CATCH
java·数据库·笔记·sql·microsoft·sqlserver
凯子坚持 c4 小时前
CANN 性能剖析实战:从原始事件到交互式火焰图
windows·microsoft
开开心心就好4 小时前
发票合并打印工具,多页布局设置实时预览
linux·运维·服务器·windows·pdf·harmonyos·1024程序员节
獨枭4 小时前
PyCharm 跑通 SAM 全流程实战
windows
仙剑魔尊重楼5 小时前
音乐制作电子软件FL Studio2025.2.4.5242中文版新功能介绍
windows·音频·录屏·音乐·fl studio
PHP小志6 小时前
Windows 服务器怎么修改密码和用户名?账户被系统锁定如何解锁
windows
专注VB编程开发20年7 小时前
vb.net datatable新增数据时改用数组缓存
java·linux·windows
仙剑魔尊重楼7 小时前
专业音乐制作软件fl Studio 2025.2.4.5242中文版新功能
windows·音乐·fl studio