$npx -y skills add microsoft/win-dev-skills --skill winui-packagingMSIX packaging, code signing, and distribution for WinUI 3 apps — build for release, certificate generation (winapp cert generate), certificate trust, code signing (winapp sign), self-contained deployment, CI/CD with GitHub Actions, and Microsoft Store submission. Use when prepar
| 1 | ### Quick Reference |
| 2 | |
| 3 | | Task | Command | |
| 4 | |------|---------| |
| 5 | | Build for release | `.\BuildAndRun.ps1 /p:Configuration=Release` | |
| 6 | | Package + sign | `winapp package <dir> --cert devcert.pfx` | |
| 7 | | Generate + sign + package | `winapp package <dir> --generate-cert --install-cert` | |
| 8 | | Generate dev certificate | `winapp cert generate` | |
| 9 | | Trust certificate (admin) | `winapp cert install ./devcert.pfx` | |
| 10 | | Sign existing file | `winapp sign ./app.msix ./devcert.pfx` | |
| 11 | | Self-contained deployment | `winapp package <dir> --cert devcert.pfx --self-contained` | |
| 12 | |
| 13 | ### End-to-End Workflow |
| 14 | |
| 15 | #### Step 1: Build for Release |
| 16 | Use the BuildAndRun.ps1 script from the `winui-dev-workflow` skill to build your app in Release configuration without launching it: |
| 17 | |
| 18 | ```powershell |
| 19 | .\BuildAndRun.ps1 /p:Configuration=Release -SkipRun |
| 20 | ``` |
| 21 | |
| 22 | #### Step 2: Generate Certificate (one-time) |
| 23 | ```powershell |
| 24 | winapp cert generate --manifest . |
| 25 | ``` |
| 26 | Creates `devcert.pfx` (default password: `password`). The `--manifest` flag auto-matches the `Publisher` field in `Package.appxmanifest`. |
| 27 | |
| 28 | #### Step 3: Trust Certificate (one-time, requires admin) |
| 29 | ```powershell |
| 30 | winapp cert install ./devcert.pfx |
| 31 | ``` |
| 32 | Adds cert to machine Trusted Root store. Persists across reboots. |
| 33 | |
| 34 | #### Step 4: Package and Sign |
| 35 | ```powershell |
| 36 | winapp package <build-output-dir> --cert ./devcert.pfx |
| 37 | ``` |
| 38 | This locates `appxmanifest.xml`, stages the layout, generates `resources.pri`, creates `.msix`, and signs it. |
| 39 | |
| 40 | #### Step 5: Install or Distribute |
| 41 | ```powershell |
| 42 | # Local install |
| 43 | Add-AppxPackage ./MyApp.msix |
| 44 | |
| 45 | # Or double-click the .msix file |
| 46 | ``` |
| 47 | |
| 48 | ### Key Rules |
| 49 | |
| 50 | - **Publisher must match** between certificate and manifest `Identity.Publisher` — use `winapp cert generate --manifest` to auto-match |
| 51 | - **Prefer `winapp package --cert`** over separate `winapp sign` — one step instead of two |
| 52 | - **`cert install` requires admin** — run terminal as Administrator |
| 53 | - **Default PFX password** is `password` — override with `--password` |
| 54 | - **`--timestamp`** is critical for production — without it, signatures expire with the cert: |
| 55 | ```powershell |
| 56 | winapp package <dir> --cert prod.pfx --timestamp http://timestamp.digicert.com |
| 57 | ``` |
| 58 | - **`--self-contained`** bundles Windows App SDK runtime — larger but no runtime dependency |
| 59 | |
| 60 | ### CI/CD with GitHub Actions |
| 61 | |
| 62 | ```yaml |
| 63 | name: Build and Package |
| 64 | on: [push] |
| 65 | jobs: |
| 66 | build: |
| 67 | runs-on: windows-latest |
| 68 | steps: |
| 69 | - uses: actions/checkout@v4 |
| 70 | - uses: microsoft/setup-WinAppCli@v0.1 |
| 71 | |
| 72 | - name: Build |
| 73 | run: dotnet build -c Release -p:Platform=x64 |
| 74 | |
| 75 | - name: Package |
| 76 | run: | |
| 77 | winapp cert generate --if-exists skip --quiet |
| 78 | winapp package ./bin/x64/Release/ --cert ./devcert.pfx --quiet |
| 79 | |
| 80 | - name: Upload artifact |
| 81 | uses: actions/upload-artifact@v4 |
| 82 | with: |
| 83 | name: msix-package |
| 84 | path: "*.msix" |
| 85 | ``` |
| 86 | |
| 87 | **CI/CD tips:** |
| 88 | - Use `--quiet` for clean output |
| 89 | - Use `--if-exists skip` with `cert generate` to avoid failures on re-runs |
| 90 | - Store production PFX as a repository secret |
| 91 | |
| 92 | ### Store Submission |
| 93 | |
| 94 | 1. **Partner Center account** — register at [partner.microsoft.com](https://partner.microsoft.com) |
| 95 | 2. **Age ratings** — complete the questionnaire in Partner Center |
| 96 | 3. **Screenshots** — capture at 1366x768 minimum resolution |
| 97 | 4. **Privacy policy** — required for apps that access internet or user data |
| 98 | 5. **Submit:** upload the signed `.msix` / `.msixbundle` produced by `winapp package` via [Microsoft Partner Center](https://partner.microsoft.com/dashboard) — Apps and games → your app → Packages. Microsoft Store submission is browser-based; there is no first-party CLI submit command yet. |
| 99 | |
| 100 | ### Troubleshooting |
| 101 | |
| 102 | | Error | Solution | |
| 103 | |-------|----------| |
| 104 | | "Publisher mismatch" | Run `winapp cert generate --manifest` to re-generate | |
| 105 | | "Certificate not trusted" | Run `winapp cert install ./devcert.pfx` as admin | |
| 106 | | "Access denied" | `cert install` needs admin elevation | |
| 107 | | "Certificate file already exists" | Use `--if-exists overwrite` or `--if-exists skip` | |
| 108 | | "appxmanifest.xml not found" | Run `winapp init` or pass `--manifest <path>` | |
| 109 | | "Package installation failed" | Trust cert first; remove stale: `Get-AppxPackage <name> \| Remove-AppxPackage` | |
| 110 | | Signature invalid after time | Re-sign with `--timestamp` | |
| 111 | |
| 112 | ### References |
| 113 | |
| 114 | | File | Read when... | |
| 115 | |------|-------------| |
| 116 | | `references/sourcegen-patterns.md` | Setting up AOT/trimming, JSON source generators, NativeAOT readiness, CsWin32 | |