用途:为常规 .exe 注册 Windows 包标识,使其能使用受限制的 API 与系统集成功能,包括推送通知(WNS)、后台任务、共享目标/源、应用启动任务、任务栏固定、Windows AI API(Phi Silica、OCR 等)以及正确注册文件类型关联。
主要能力:winapp create-debug-identity 通过稀疏包(sparse package)注册标识,exe 留在原位置,使用 Add-AppxPackage -ExternalLocation 关联标识;默认在包名后追加 .debug,可用 --keep-identity 保留原标识,--no-install 只生成不注册。winapp run 注册完整 loose layout 包并启动应用,模拟 MSIX 安装;并行工作树用 winapp run . --unique-identity --no-launch --json,清理用 winapp unregister .。生产场景可用 winapp init --exe ... --sparse、winapp pack ... --cert、winapp embed-identity 生成签名的仅标识 .msix。
必要用法:winapp create-debug-identity ./bin/Release/myapp.exe [--manifest ./Package.appxmanifest];常规开发优先 winapp run <build-output>。生产:先 winapp init --exe ./bin/Release/MyApp.exe --sparse --use-defaults,再 winapp pack ./sparse/appxmanifest.xml --cert ./devcert.pfx,最后 winapp embed-identity ./bin/Release/MyApp.exe。
适用场景:调试启动代码、exe 独立于构建输出(如 Electron 的 node_modules 中的 electron.exe)、测试稀疏包行为;VS Code、终端开发及 Rust、Flutter、Tauri、Electron、C++ 等 VS 不原生打包的框架。
限制:需先有 Package.appxmanifest 和已构建的可执行文件;create-debug-identity 为开发期调试用途,需开发者模式;修改清单或 Assets 后须重新运行;调试标识会跨重启保留至显式移除;需可信证书。Electron 请改用 npx winapp node add-electron-debug-identity。