winui-packaging
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseQuick Reference
快速参考
| Task | Command |
|---|---|
| Build for release | |
| Package + sign | |
| Generate + sign + package | |
| Generate dev certificate | |
| Trust certificate (admin) | |
| Sign existing file | |
| Self-contained deployment | |
| 任务 | 命令 |
|---|---|
| 构建发布版本 | |
| 打包 + 签名 | |
| 生成证书 + 签名 + 打包 | |
| 生成开发证书 | |
| 信任证书(管理员权限) | |
| 签名已有文件 | |
| 独立部署 | |
End-to-End Workflow
端到端工作流程
Step 1: Build for Release
步骤1:构建发布版本
Use the BuildAndRun.ps1 script from the skill to build your app in Release configuration without launching it:
winui-dev-workflowpowershell
.\BuildAndRun.ps1 /p:Configuration=Release -SkipRun使用技能中的BuildAndRun.ps1脚本,以Release配置构建应用但不启动:
winui-dev-workflowpowershell
.\BuildAndRun.ps1 /p:Configuration=Release -SkipRunStep 2: Generate Certificate (one-time)
步骤2:生成证书(一次性操作)
powershell
winapp cert generate --manifest .Creates (default password: ). The flag auto-matches the field in .
devcert.pfxpassword--manifestPublisherPackage.appxmanifestpowershell
winapp cert generate --manifest .生成文件(默认密码:)。参数会自动匹配中的字段。
devcert.pfxpassword--manifestPackage.appxmanifestPublisherStep 3: Trust Certificate (one-time, requires admin)
步骤3:信任证书(一次性操作,需管理员权限)
powershell
winapp cert install ./devcert.pfxAdds cert to machine Trusted Root store. Persists across reboots.
powershell
winapp cert install ./devcert.pfx将证书添加到机器的受信任根证书存储区,重启后依然有效。
Step 4: Package and Sign
步骤4:打包并签名
powershell
winapp package <build-output-dir> --cert ./devcert.pfxThis locates , stages the layout, generates , creates , and signs it.
appxmanifest.xmlresources.pri.msixpowershell
winapp package <build-output-dir> --cert ./devcert.pfx该命令会定位、准备布局、生成、创建文件并完成签名。
appxmanifest.xmlresources.pri.msixStep 5: Install or Distribute
步骤5:安装或分发
powershell
undefinedpowershell
undefinedLocal install
本地安装
Add-AppxPackage ./MyApp.msix
Add-AppxPackage ./MyApp.msix
Or double-click the .msix file
或双击.msix文件
undefinedundefinedKey Rules
关键规则
- Publisher must match between certificate and manifest — use
Identity.Publisherto auto-matchwinapp cert generate --manifest - Prefer over separate
winapp package --cert— one step instead of twowinapp sign - requires admin — run terminal as Administrator
cert install - Default PFX password is — override with
password--password - is critical for production — without it, signatures expire with the cert:
--timestamppowershellwinapp package <dir> --cert prod.pfx --timestamp http://timestamp.digicert.com - bundles Windows App SDK runtime — larger but no runtime dependency
--self-contained
- 发布者信息必须匹配:证书与清单中的发布者信息需一致——使用
Identity.Publisher可自动匹配winapp cert generate --manifest - 优先使用:相比单独执行
winapp package --cert,一步完成打包和签名winapp sign - 需要管理员权限:需以管理员身份运行终端
cert install - 默认PFX密码为:可通过
password参数覆盖--password - 对生产环境至关重要:如果不添加该参数,签名会随证书过期而失效:
--timestamppowershellwinapp package <dir> --cert prod.pfx --timestamp http://timestamp.digicert.com - ****会捆绑Windows App SDK运行时:安装包体积更大,但无需依赖外部运行时
--self-contained
CI/CD with GitHub Actions
基于GitHub Actions的CI/CD流程
yaml
name: Build and Package
on: [push]
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: microsoft/setup-WinAppCli@v0.1
- name: Build
run: dotnet build -c Release -p:Platform=x64
- name: Package
run: |
winapp cert generate --if-exists skip --quiet
winapp package ./bin/x64/Release/ --cert ./devcert.pfx --quiet
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: msix-package
path: "*.msix"CI/CD tips:
- Use for clean output
--quiet - Use with
--if-exists skipto avoid failures on re-runscert generate - Store production PFX as a repository secret
yaml
name: Build and Package
on: [push]
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- uses: microsoft/setup-WinAppCli@v0.1
- name: Build
run: dotnet build -c Release -p:Platform=x64
- name: Package
run: |
winapp cert generate --if-exists skip --quiet
winapp package ./bin/x64/Release/ --cert ./devcert.pfx --quiet
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: msix-package
path: "*.msix"CI/CD提示:
- 使用参数获得简洁输出
--quiet - 在中使用
cert generate避免重复运行时失败--if-exists skip - 将生产环境PFX文件存储为仓库密钥
Store Submission
Microsoft Store提交流程
- Partner Center account — register at partner.microsoft.com
- Age ratings — complete the questionnaire in Partner Center
- Screenshots — capture at 1366x768 minimum resolution
- Privacy policy — required for apps that access internet or user data
- Submit: upload the signed /
.msixproduced by.msixbundlevia Microsoft Partner Center — Apps and games → your app → Packages. Microsoft Store submission is browser-based; there is no first-party CLI submit command yet.winapp package
- 合作伙伴中心账户——前往partner.microsoft.com注册
- 年龄分级——在合作伙伴中心完成问卷
- 截图——捕获分辨率不低于1366x768的截图
- 隐私政策——访问互联网或用户数据的应用必须提供隐私政策
- 提交:通过Microsoft合作伙伴中心上传由生成的已签名
winapp package/.msix文件——进入“应用和游戏”→你的应用→“包”。Microsoft Store提交目前仅支持浏览器操作,暂无官方CLI提交命令。.msixbundle
Troubleshooting
故障排查
| Error | Solution |
|---|---|
| "Publisher mismatch" | Run |
| "Certificate not trusted" | Run |
| "Access denied" | |
| "Certificate file already exists" | Use |
| "appxmanifest.xml not found" | Run |
| "Package installation failed" | Trust cert first; remove stale: |
| Signature invalid after time | Re-sign with |
| 错误 | 解决方案 |
|---|---|
| “发布者信息不匹配” | 运行 |
| “证书未被信任” | 以管理员身份运行 |
| “访问被拒绝” | |
| “证书文件已存在” | 使用 |
| “未找到appxmanifest.xml” | 运行 |
| “包安装失败” | 先信任证书;移除旧版本:`Get-AppxPackage <name> |
| 签名随时间失效 | 使用 |
References
参考资料
| File | Read when... |
|---|---|
| Setting up AOT/trimming, JSON source generators, NativeAOT readiness, CsWin32 |
| 文件 | 适用场景 |
|---|---|
| 配置AOT/裁剪、JSON源生成器、NativeAOT就绪、CsWin32时阅读 |