winapp-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseWindows App Development CLI
Windows应用开发CLI
The Windows App Development CLI () is a command-line interface for managing Windows SDKs, MSIX packaging, generating app identity, manifests, certificates, and using build tools with any app framework. It bridges the gap between cross-platform development and Windows-native capabilities.
winappWindows应用开发CLI()是一个命令行界面工具,用于管理Windows SDK、MSIX打包、生成应用标识、清单、证书,以及在任意应用框架中使用构建工具。它填补了跨平台开发与Windows原生功能之间的差距。
winappWhen to Use This Skill
何时使用该工具
Use this skill when you need to:
- Initialize a Windows app project with SDK setup, manifests, and certificates
- Create MSIX packages from application directories
- Generate or manage AppxManifest.xml files
- Create and install development certificates for signing
- Add package identity for debugging Windows APIs
- Sign MSIX packages or executables
- Access Windows SDK build tools from any framework
- Build Windows apps using cross-platform frameworks (Electron, Rust, Tauri, Qt)
- Set up CI/CD pipelines for Windows app deployment
- Access Windows APIs that require package identity (notifications, Windows AI, shell integration)
当你需要以下操作时,可以使用本工具:
- 初始化包含SDK配置、清单和证书的Windows应用项目
- 从应用目录创建MSIX包
- 生成或管理AppxManifest.xml文件
- 创建并安装用于签名的开发证书
- 添加包标识以调试Windows API
- 为MSIX包或可执行文件签名
- 从任意框架访问Windows SDK构建工具
- 使用跨平台框架(Electron、Rust、Tauri、Qt)构建Windows应用
- 为Windows应用部署设置CI/CD流水线
- 访问需要包标识的Windows API(通知、Windows AI、外壳集成)
Prerequisites
前置条件
- Windows 10 or later
- winapp CLI installed via one of these methods:
- WinGet:
winget install Microsoft.WinAppCli --source winget - NPM (for Electron):
npm install @microsoft/winappcli --save-dev - GitHub Actions/Azure DevOps: Use setup-WinAppCli action
- Manual: Download from GitHub Releases
- WinGet:
- Windows 10或更高版本
- 通过以下方式之一安装winapp CLI:
- WinGet:
winget install Microsoft.WinAppCli --source winget - NPM(适用于Electron):
npm install @microsoft/winappcli --save-dev - GitHub Actions/Azure DevOps:使用setup-WinAppCli动作
- 手动安装:从GitHub Releases下载
- WinGet:
Core Capabilities
核心功能
1. Project Initialization (winapp init
)
winapp init1. 项目初始化(winapp init
)
winapp initInitialize a directory with required assets (manifest, certificates, libraries) for building a modern Windows app. Supports SDK installation modes: , , , or .
stablepreviewexperimentalnone为构建现代Windows应用初始化目录,包含所需资源(清单、证书、库)。支持SDK安装模式:、、或。
stablepreviewexperimentalnone2. MSIX Packaging (winapp pack
)
winapp pack2. MSIX打包(winapp pack
)
winapp packCreate MSIX packages from prepared directories with optional signing, certificate generation, and self-contained deployment bundling.
从已准备好的目录创建MSIX包,支持可选的签名、证书生成和自包含部署捆绑。
3. Package Identity for Debugging (winapp create-debug-identity
)
winapp create-debug-identity3. 调试用包标识(winapp create-debug-identity
)
winapp create-debug-identityAdd temporary package identity to executables for debugging Windows APIs that require identity (notifications, Windows AI, shell integration) without full packaging.
为可执行文件添加临时包标识,无需完整打包即可调试需要标识的Windows API(通知、Windows AI、外壳集成)。
4. Manifest Management (winapp manifest
)
winapp manifest4. 清单管理(winapp manifest
)
winapp manifestGenerate AppxManifest.xml files and update image assets from source images, automatically creating all required sizes and aspect ratios.
生成AppxManifest.xml文件,并从源图片更新图像资源,自动创建所有所需尺寸和宽高比的资源。
5. Certificate Management (winapp cert
)
winapp cert5. 证书管理(winapp cert
)
winapp certGenerate development certificates and install them to the local machine store for signing packages.
生成开发证书并安装到本地计算机存储,用于包签名。
6. Package Signing (winapp sign
)
winapp sign6. 包签名(winapp sign
)
winapp signSign MSIX packages and executables with PFX certificates, with optional timestamp server support.
使用PFX证书为MSIX包和可执行文件签名,支持可选的时间戳服务器。
7. SDK Build Tools Access (winapp tool
)
winapp tool7. SDK构建工具访问(winapp tool
)
winapp toolRun Windows SDK build tools with properly configured paths from any framework or build system.
从任意框架或构建系统运行配置好路径的Windows SDK构建工具。
Usage Examples
使用示例
Example 1: Initialize and Package a Windows App
示例1:初始化并打包Windows应用
bash
undefinedbash
undefinedInitialize workspace with defaults
使用默认设置初始化工作区
winapp init
winapp init
Build your application (framework-specific)
构建应用(取决于具体框架)
...
...
Create signed MSIX package
创建已签名的MSIX包
winapp pack ./build-output --generate-cert --output MyApp.msix
undefinedwinapp pack ./build-output --generate-cert --output MyApp.msix
undefinedExample 2: Debug with Package Identity
示例2:使用包标识调试
bash
undefinedbash
undefinedAdd debug identity to executable for testing Windows APIs
为可执行文件添加调试标识以测试Windows API
winapp create-debug-identity ./bin/MyApp.exe
winapp create-debug-identity ./bin/MyApp.exe
Run your app - it now has package identity
运行应用 - 现在已具备包标识
./bin/MyApp.exe
undefined./bin/MyApp.exe
undefinedExample 3: CI/CD Pipeline Setup
示例3:CI/CD流水线设置
yaml
undefinedyaml
undefinedGitHub Actions example
GitHub Actions示例
-
name: Setup winapp CLI uses: microsoft/setup-WinAppCli@v1
-
name: Initialize and Package run: | winapp init --no-prompt winapp pack ./build-output --output MyApp.msix
undefined-
name: Setup winapp CLI uses: microsoft/setup-WinAppCli@v1
-
name: Initialize and Package run: | winapp init --no-prompt winapp pack ./build-output --output MyApp.msix
undefinedExample 4: Electron App Integration
示例4:Electron应用集成
bash
undefinedbash
undefinedInstall via npm
通过npm安装
npm install @microsoft/winappcli --save-dev
npm install @microsoft/winappcli --save-dev
Initialize and add debug identity for Electron
初始化并为Electron添加调试标识
npx winapp init
npx winapp node add-electron-debug-identity
npx winapp init
npx winapp node add-electron-debug-identity
Package for distribution
打包用于分发
npx winapp pack ./out --output MyElectronApp.msix
undefinednpx winapp pack ./out --output MyElectronApp.msix
undefinedGuidelines
使用指南
- Run first - Always initialize your project before using other commands to ensure SDK setup, manifest, and certificates are configured.
winapp init - Re-run after manifest changes - Package identity must be recreated whenever AppxManifest.xml is modified.
create-debug-identity - Use for CI/CD - Prevents interactive prompts in automated pipelines by using default values.
--no-prompt - Use for shared projects - Recreates the exact environment state defined in
winapp restoreacross machines.winapp.yaml - Generate assets from a single image - Use with one logo to generate all required icon sizes.
winapp manifest update-assets
- 先运行- 在使用其他命令前,务必先初始化项目,确保SDK配置、清单和证书已正确设置。
winapp init - 修改清单后重新运行- 每当AppxManifest.xml被修改时,必须重新创建包标识。
create-debug-identity - 在CI/CD中使用- 在自动化流水线中使用默认值,避免交互式提示。
--no-prompt - 为共享项目使用- 在不同机器上根据
winapp restore重新创建完全一致的环境状态。winapp.yaml - 从单张图片生成资源 - 使用和一张Logo生成所有所需尺寸的图标。
winapp manifest update-assets
Common Patterns
常见使用模式
Pattern: Initialize New Project
模式:初始化新项目
bash
cd my-project
winapp initbash
cd my-project
winapp initCreates: AppxManifest.xml, development certificate, SDK configuration, winapp.yaml
创建:AppxManifest.xml、开发证书、SDK配置、winapp.yaml
undefinedundefinedPattern: Package with Existing Certificate
模式:使用现有证书打包
bash
winapp pack ./build-output --cert ./mycert.pfx --cert-password secret --output MyApp.msixbash
winapp pack ./build-output --cert ./mycert.pfx --cert-password secret --output MyApp.msixPattern: Self-Contained Deployment
模式:自包含部署
bash
undefinedbash
undefinedBundle Windows App SDK runtime with the package
将Windows App SDK运行时与包捆绑
winapp pack ./my-app --self-contained --generate-cert
undefinedwinapp pack ./my-app --self-contained --generate-cert
undefinedPattern: Update Package Versions
模式:更新包版本
bash
undefinedbash
undefinedUpdate to latest stable SDKs
更新到最新稳定版SDK
winapp update
winapp update
Or update to preview SDKs
或更新到预览版SDK
winapp update --setup-sdks preview
undefinedwinapp update --setup-sdks preview
undefinedLimitations
局限性
- Windows 10 or later required (Windows-only CLI)
- Package identity debugging requires re-running after any manifest changes
create-debug-identity - Self-contained deployment increases package size by bundling the Windows App SDK runtime
- Development certificates are for testing only; production requires trusted certificates
- Some Windows APIs require specific capability declarations in the manifest
- winapp CLI is in public preview and subject to change
- 需要Windows 10或更高版本(仅支持Windows的CLI)
- 包标识调试需要在修改清单后重新运行
create-debug-identity - 自包含部署会因捆绑Windows App SDK运行时而增加包体积
- 开发证书仅用于测试;生产环境需要受信任的证书
- 部分Windows API需要在清单中声明特定权限
- winapp CLI处于公开预览阶段,可能会有变更
Windows APIs Enabled by Package Identity
包标识解锁的Windows API
Package identity unlocks access to powerful Windows APIs:
| API Category | Examples |
|---|---|
| Notifications | Interactive native notifications, notification management |
| Windows AI | On-device LLM, text/image AI APIs (Phi Silica, Windows ML) |
| Shell Integration | Explorer, Taskbar, Share sheet integration |
| Protocol Handlers | Custom URI schemes ( |
| Device Access | Camera, microphone, location (with consent) |
| Background Tasks | Run when app is closed |
| File Associations | Open file types with your app |
包标识可解锁对强大Windows API的访问权限:
| API类别 | 示例 |
|---|---|
| 通知 | 交互式原生通知、通知管理 |
| Windows AI | 本地LLM、文本/图像AI API(Phi Silica、Windows ML) |
| 外壳集成 | 文件资源管理器、任务栏、共享面板集成 |
| 协议处理程序 | 自定义URI方案( |
| 设备访问 | 摄像头、麦克风、位置(需用户授权) |
| 后台任务 | 应用关闭后仍可运行 |
| 文件关联 | 使用你的应用打开特定文件类型 |
Troubleshooting
故障排除
| Issue | Solution |
|---|---|
| Certificate not trusted | Run |
| Package identity not working | Run |
| SDK not found | Run |
| Signing fails | Verify certificate password and ensure cert is not expired |
| 问题 | 解决方案 |
|---|---|
| 证书不被信任 | 运行 |
| 包标识不生效 | 修改清单后重新运行 |
| 找不到SDK | 运行 |
| 签名失败 | 验证证书密码,确保证书未过期 |