AGENT SKILL

Windows 应用打包故障排查

winapp-troubleshoot

诊断 Windows 应用的打包、签名、安装、标识和 SDK 错误:不受信任或不匹配的证书、Add-AppxPackage 和 0x80073CFx 安装失败、无包标识、C++/WinRT 头文件未生成。适用于 MSIX 无法安装或构建,或出现错误代码的情况。

License 许可
MIT
最近更新
2026-11-14
Stars
★ 1.4k
Forks
96

01 前言 Front Matter

name
winapp-troubleshoot
description
Diagnose Windows app packaging, signing, install, identity, and SDK errors: untrusted or mismatched certificates, Add-AppxPackage and 0x80073CFx install failures, no package identity, C++/WinRT headers not generated. Use when an MSIX won't install or build, or an error code appears.

03 SKILL.md 正文

If you can't run winapp yourself (no shell, or the command is denied), give the user the exact winapp command(s) for their project instead of only describing the steps.

When to use

Use this skill when:

  • Diagnosing errors from winapp CLI commands
  • Choosing the right command for a task
  • Understanding prerequisites — what each command needs and what it produces

Common errors & solutions

For slow WinUI layout or scrolling, use the winapp-performance skill. ETW performance capture is separate from debugger output and crash analysis.

Error Cause Solution
"winapp.yaml not found" Running restore or update without config Run winapp init first, or cd to the directory containing winapp.yaml
"Package.appxmanifest not found" Running package, create-debug-identity, or cert generate --manifest Run winapp init or winapp manifest generate first, or pass --manifest <path>
"Publisher mismatch" Certificate publisher ≠ manifest publisher Regenerate cert: winapp cert generate --manifest, or edit Package.appxmanifest Identity.Publisher to match
"Access denied" / "elevation required" cert install without admin Run terminal as Administrator for winapp cert install
"Package installation failed" Cert not trusted, or stale package registration For a certificate error, winapp cert install ./devcert.pfx (admin). For registration conflicts, see the rows below rather than deleting packages by name
"Certificate not trusted" Dev cert not installed on machine winapp cert install ./devcert.pfx (admin)
"Build tools not found" First run, tools not yet downloaded Run winapp update to download tools; ensure internet access
"Failed to add package identity" Stale debug identity or untrusted cert Run winapp unregister with your app's input (or --manifest for create-debug-identity); install a certificate only if the error asks for it
"Certificate file already exists" devcert.pfx already present Use winapp cert generate --if-exists overwrite or --if-exists skip
"Manifest already exists" Package.appxmanifest already present Use winapp manifest generate --if-exists overwrite or edit manifest directly
run / create-debug-identity registration error 0x800704EC Developer Mode is disabled Enable it in Settings → Privacy & security → For developers, or Set-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock' -Name AllowDevelopmentWithoutDevLicense -Value 1, then retry
Two worktrees of the same app keep replacing each other's registration Both copies share one package identity Run each with winapp run . --unique-identity (supported packaged apps) so each gets its own identity and app data
run / create-debug-identity registration error 0x80073CFB Package already registered with a conflicting identity Run winapp unregister with your app's input, then retry. Use --force only if you are sure the same-named package registered elsewhere is yours
App's Start menu entry launches nothing, silently Package still registered after its files were deleted Run winapp unregister --prune to remove every dev registration whose files are gone
run reports access denied or a file in use during a rebuild Permissions or a file held open; access denied alone does not identify a lock owner Check the reported paths and permissions. winapp run closes a copy of the app running from the same layout before replacing its files; close any other process holding the file and retry.
"winapp can't write the API index" / "can't install the Microsoft Store Developer CLI" %USERPROFILE%\.winapp isn't writable (for example, an agent sandbox) Set WINAPP_CLI_CACHE_DIRECTORY to a writable folder, such as one inside the project, and retry. Other commands keep working without it

For --unique-identity errors about unsupported extensions or resources, see unique identity for parallel checkouts. Run without the flag instead of working around the check.

Command selection guide

Is the app a single .cs file (.NET file-based app)?
├─ Yes → winapp run <file>.cs  (builds it and generates the manifest for you)
└─ No → Does the project have a Package.appxmanifest?
   ├─ No → Do you want full setup (manifest + config + optional SDKs)?
   │       ├─ Yes → winapp init (adds Windows platform files to existing project)
   │       └─ No, just a manifest → winapp manifest generate
   └─ Yes
      ├─ Has winapp.yaml, cloned/pulled but .winapp/ folder missing?
      │  └─ winapp restore
      ├─ Want newer SDK versions?
      │  └─ winapp update
      ├─ Need a dev certificate?
      │  └─ winapp cert generate (then winapp cert install for trust)
      ├─ Need package identity for debugging? (see [Debugging Guide](https://github.com/microsoft/WinAppCli/blob/main/docs/debugging.md))
      │  ├─ Exe is in your build output folder? (most frameworks)
      │  │  └─ winapp run <build-output-dir>
      │  └─ Exe is separate from app code? (Electron, sparse testing)
      │     └─ winapp create-debug-identity <exe>
      ├─ Ready to create MSIX installer?
      │  └─ winapp package <build-output> --cert ./devcert.pfx
      ├─ Need to sign an existing file?
      │  └─ winapp sign <file> <cert>
      ├─ Need to update app icons?
      │  └─ winapp manifest update-assets ./logo.png
      ├─ Need to run SDK tools directly?
      │  └─ winapp tool <toolname> <args>
      ├─ Need to publish to Microsoft Store?
      │  └─ winapp store <args> (passthrough to Store Developer CLI)
      └─ Need the .winapp directory path for build scripts?
         └─ winapp get-winapp-path (or --global for shared cache)

Important notes:

  • winapp init adds files to an existing project — it does not create a new project
  • The key prerequisite for most commands is Package.appxmanifest, not winapp.yaml
  • winapp.yaml is only needed for SDK version management (restore/update)
  • Projects with NuGet package references (e.g., .csproj referencing Microsoft.Windows.SDK.BuildTools) can use winapp commands without winapp.yaml
  • For Electron projects, use the npm package (npm install --save-dev @microsoft/winappcli) which includes Node.js-specific commands under npx winapp node

Debugging approach quick reference

Goal Command Key detail
Run with identity (most common) winapp run .\build\Debug Registers loose layout + launches; a console app gets an execution alias automatically
Attach debugger to running app winapp run .\build\Debug → attach to PID Misses startup code
Register identity, launch manually winapp run .\build\Debug --no-launch Launch via start shell:AppsFolder\<AUMID> or execution alias — not the exe directly
F5 startup debugging (IDE launches exe) winapp create-debug-identity .\bin\myapp.exe Exe has identity regardless of how it's launched; best for debugging activation/startup code
Capture OutputDebugString + crash dump winapp run .\build\Debug --debug-output On crash, writes minidump and shows exception type, message, and faulting methods. Blocks other debuggers — use --no-launch if you need VS Code/WinDbg
Run and auto-clean winapp run .\build\Debug --unregister-on-exit Unregisters the dev package after the app exits
Launch and detach (CI) winapp run .\build\Debug --detach Returns immediately after launch; use --json to get PID for scripting
Clean up this app's registration winapp unregister . Pass the same input as run; works with or without --unique-identity
Start menu entry does nothing when clicked winapp unregister --prune The package is registered but its files were deleted, so activation silently fails. Prune removes every dev registration whose files are gone

Visual Studio users: If you have a packaging project, VS already handles identity and debugging from F5 — you likely don't need winapp for debugging. These workflows are for VS Code, terminal, and frameworks VS doesn't natively package.

For full details, see the Debugging Guide.

Prerequisites & state matrix

Command Requires Creates/Modifies
init Existing project (any framework) winapp.yaml, .winapp/, Package.appxmanifest, Assets/, .gitignore update
restore winapp.yaml .winapp/packages/, generated projections
update winapp.yaml Updates versions in winapp.yaml, reinstalls packages
manifest generate Nothing Package.appxmanifest, Assets/
manifest update-assets Package.appxmanifest + source image Regenerates Assets/ icons
cert generate Nothing (or Package.appxmanifest for publisher) devcert.pfx
cert install Certificate file + admin Machine certificate store
create-debug-identity Package.appxmanifest + exe + trusted cert Registers sparse package with Windows
run Build output folder + Package.appxmanifest; or a .csproj/.vcxproj/.sln (C++ needs Visual Studio or Build Tools with the C++ workload); or a .cs file-based app (no manifest needed — one is generated) Registers loose layout package, launches app
unregister The same input passed to run (.cs, .csproj/.vcxproj, or folder), or --manifest Removes the development registration that run or create-debug-identity created
package Build output + Package.appxmanifest .msix file
sign File + certificate Signed file (in-place)
create-external-catalog Directory with executables CodeIntegrityExternal.cat
tool <name> Nothing (auto-downloads tools) Runs SDK tool directly
store Nothing (auto-downloads Store CLI) Passthrough to Microsoft Store Developer CLI
get-winapp-path Nothing Prints .winapp directory path

Debugging tips

  • Add --verbose (or -v) to any command for detailed output
  • Add --quiet (or -q) to suppress progress messages (useful in CI/CD)
  • Run winapp --cli-schema to get the full JSON schema of all commands and options
  • Run any command with --help for its specific usage information
  • Use winapp get-winapp-path to find where packages are stored locally
  • Use winapp get-winapp-path --global to find the shared cache location

Getting more help

Related skills

  • Setup & init: winapp-setup — adding Windows support to a project
  • Manifest: winapp-manifest — creating and editing Package.appxmanifest
  • Signing: winapp-signing — certificate generation and management
  • Packaging: winapp-package — creating MSIX installers
  • Identity: winapp-identity — enabling package identity for Windows APIs
  • Frameworks: winapp-frameworks — framework-specific guidance (Electron, .NET, C++, Rust, Flutter, Tauri)
  • MAUI: winapp-maui — packaging/signing .NET MAUI Windows apps and resolving the resizetizer manifest

CLI reference

Run winapp <command> --help for current command options, or winapp --cli-schema for the complete machine-readable command schema.

04 同仓库更多 Skills

microsoft
microsoft/winappCli

WPF 至 WinUI 3 应用迁移

winui-wpf-migration

将 WPF 应用迁移或移植到 WinUI 3:命名空间(System.Windows 到 Microsoft.UI.Xaml)、控件映射(DataGrid、WrapPanel、TabControl)、Dispatcher 到 DispatcherQueue、图像处理、使用 CommunityToolkit.Mvvm 的 MVVM、ThemeResource。在转换 WPF 代码或修复迁移构建错误时使用。

软件开发工程师代码实现
★ 1.4k
microsoft
microsoft/winappCli

Windows 桌面应用 UI 自动化测试

winui-ui-testing

使用 winapp ui harness 为 Windows 桌面应用(WinUI 3、WPF、WinForms、Win32)编写并运行自动化 UI 测试:一个批处理脚本,支持断言、输入、文件选择器、对话框、截图,可在本地或 Windows Sandbox 中运行。当用户要求 UI 测试或端到端验证某个功能时使用。

测试工程师测试与质量保障
★ 1.4k
microsoft
microsoft/winappCli

WinUI 3 开发环境配置

winui-setup

安装并验证 WinUI 3 的先决条件——.NET SDK 8.0.100+、WinApp CLI 0.7+ 以及开发者模式;识别 Native AOT 和 Windows Sandbox 的额外要求。当用户请求设置或修复工具链,或其他 WinUI 技能发现先决条件缺失或过时时使用。

软件开发工程师开发环境与工具链管理
★ 1.4k
microsoft
microsoft/winappCli

WinUI 3 应用打包与发布

winui-packaging

使用 WinApp CLI 0.7+ 对 WinUI 3 应用进行 MSIX 打包、签名并发布到 Microsoft Store:包括项目打包、Native AOT、证书、自包含部署和 CI/CD。在发布 WinUI 应用时使用。不适用于仅引用 Windows App SDK 的 WPF、WinForms 或 Electron 应用。

软件开发工程师部署与发布管理
★ 1.4k
microsoft
microsoft/winappCli

WinUI 应用开发工作流

winui-dev-workflow

使用 WinApp CLI 0.7+ 创建、构建、运行 WinUI 3 应用(C# 或 C++)并修复构建错误:winapp new、winapp run、Native AOT、崩溃诊断。适用于新建 WinUI 应用,或构建失败、发生崩溃的 WinUI 项目。不适用于仅引用 Windows App SDK 的 WPF、WinForms 或 Electron 应用。

软件开发工程师开发环境与工具链管理
★ 1.4k
microsoft
microsoft/winappCli

WinUI XAML 界面设计

winui-design

在编写或更改 WinUI 3 XAML 之前阅读:控件、页面与导航的选择、布局、Fluent Design、主题、可访问性、x:Bind、真实示例,以及使用 winapp find-api 检查 API 是否存在。不适用于 WPF 或 WinForms UI,即使应用使用了 Windows App SDK。

软件开发工程师前端开发与界面实现
★ 1.4k