Microsoft Store Developer CLI (msstore) 是用於將 Windows 應用程式發佈到 Microsoft Store 的命令列工具。當需要設定 Store 認證、列出 Store 應用程式、檢查提交狀態、發佈提交、管理套件測試群組、設定 CI/CD 發佈流程或與合作夥伴中心整合時使用。支援 Windows App SDK/WinUI、UWP、.NET MAUI、Flutter、Electron、React Native 及 PWA 應用程式。
Microsoft Store Developer CLI (msstore)
Microsoft Store Developer CLI (msstore) 是一個跨平台命令列介面,用於發佈和管理 Microsoft Store 中的應用程式。它與合作夥伴中心 API 整合,支援多種應用程式類型的自動化發佈工作流程。
何時使用此技能
當您需要以下操作時,請使用此技能:
- 設定 Store 認證以存取 API
- 列出 Store 帳戶中的應用程式
- 檢查提交狀態
- 將提交發佈到 Store
- 為 Store 提交封裝應用程式
- 初始化專案以進行 Store 發佈
- 管理套件測試群組(Beta 測試)
- 設定 CI/CD 管線以自動化 Store 發佈
- 管理提交的逐步推出
- 以程式方式更新提交中繼資料
先決條件
- Windows 10+、macOS 或 Linux
- .NET 9 Desktop Runtime(Windows)或 .NET 9 Runtime(macOS/Linux)
- 具有適當權限的合作夥伴中心帳戶
- 已註冊 Azure AD 應用程式並具有合作夥伴中心 API 存取權限
- 透過以下其中一種方式安裝 msstore CLI:
- Microsoft Store:下載
- WinGet:
winget install "Microsoft Store Developer CLI" - 手動安裝:從 GitHub Releases 下載
合作夥伴中心設定
在使用 msstore 之前,您需要建立一個具有合作夥伴中心存取權限的 Azure AD 應用程式:
- 前往 合作夥伴中心
- 導覽至 帳戶設定 > 使用者管理 > Azure AD 應用程式
- 建立新的應用程式,並記下 租用戶識別碼、用戶端識別碼 和 用戶端密碼
- 授予應用程式適當的權限(管理員或開發人員角色)
核心命令參考
info - 列印設定
顯示目前的認證設定。
msstore info
選項:
| 選項 | 說明 |
|---|---|
-v, --verbose |
列印詳細輸出 |
reconfigure - 設定認證
設定或更新 Microsoft Store API 認證。
msstore reconfigure [options]
選項:
| 選項 | 說明 |
|---|---|
-t, --tenantId |
Azure AD 租用戶識別碼 |
-s, --sellerId |
合作夥伴中心賣家識別碼 |
-c, --clientId |
Azure AD 應用程式用戶端識別碼 |
-cs, --clientSecret |
用於驗證的用戶端密碼 |
-ct, --certificateThumbprint |
憑證指紋(替代用戶端密碼) |
-cfp, --certificateFilePath |
憑證檔案路徑(替代用戶端密碼) |
-cp, --certificatePassword |
憑證密碼 |
--reset |
重設認證而不完整重新設定 |
範例:
# 使用用戶端密碼設定
msstore reconfigure --tenantId $TENANT_ID --sellerId $SELLER_ID --clientId $CLIENT_ID --clientSecret $CLIENT_SECRET
# 使用憑證設定
msstore reconfigure --tenantId $TENANT_ID --sellerId $SELLER_ID --clientId $CLIENT_ID --certificateFilePath ./cert.pfx --certificatePassword MyPassword
settings - CLI 設定
變更 Microsoft Store Developer CLI 的設定。
msstore settings [options]
選項:
| 選項 | 說明 |
|---|---|
-t, --enableTelemetry |
啟用 (true) 或停用 (false) 遙測 |
設定發行者顯示名稱
msstore settings setpdn <publisherDisplayName>
設定 init 命令的預設發行者顯示名稱。
apps - 應用程式管理
列出並擷取應用程式資訊。
列出應用程式
msstore apps list
列出合作夥伴中心帳戶中的所有應用程式。
取得應用程式詳細資料
msstore apps get <productId>
引數:
| 引數 | 說明 |
|---|---|
productId |
Store 產品識別碼(例如 9NBLGGH4R315) |
範例:
# 取得特定應用程式的詳細資料
msstore apps get 9NBLGGH4R315
submission - 提交管理
管理 Store 提交。
| 子命令 | 說明 |
|---|---|
status |
取得提交狀態 |
get |
取得提交中繼資料和套件資訊 |
getListingAssets |
取得提交的刊登資產 |
updateMetadata |
更新提交中繼資料 |
poll |
輪詢提交狀態直到完成 |
publish |
發佈提交 |
delete |
刪除提交 |
取得提交狀態
msstore submission status <productId>
取得提交詳細資料
msstore submission get <productId>
更新中繼資料
msstore submission updateMetadata <productId> <metadata>
其中 <metadata> 是包含更新中繼資料的 JSON 字串。由於 JSON 包含 shell 會解譯的字元(引號、大括號等),您必須適當地加上引號或跳脫:
- Bash/Zsh:將 JSON 用單引號括起來,讓 shell 直接傳遞。
msstore submission updateMetadata 9NBLGGH4R315 '{"description":"My updated app"}' - PowerShell:使用單引號(或在雙引號字串內跳脫雙引號)。
msstore submission updateMetadata 9NBLGGH4R315 '{"description":"My updated app"}' - cmd.exe:在每個內部雙引號前加上反斜線跳脫。
msstore submission updateMetadata 9NBLGGH4R315 "{\"description\":\"My updated app\"}"
提示: 對於複雜或多行中繼資料,請將 JSON 儲存到檔案並傳遞其內容以避免引號問題:
msstore submission updateMetadata 9NBLGGH4R315 "$(cat metadata.json)"
選項:
| 選項 | 說明 |
|---|---|
-s, --skipInitialPolling |
跳過初始狀態輪詢 |
發佈提交
msstore submission publish <productId>
輪詢提交
msstore submission poll <productId>
輪詢直到提交狀態為 PUBLISHED 或 FAILED。
刪除提交
msstore submission delete <productId>
選項:
| 選項 | 說明 |
|---|---|
--no-confirm |
跳過確認提示 |
init - 初始化專案以發佈到 Store
初始化專案以進行 Microsoft Store 發佈。自動偵測專案類型並設定 Store 身分。
msstore init <pathOrUrl> [options]
引數:
| 引數 | 說明 |
|---|---|
pathOrUrl |
專案目錄路徑或 PWA URL |
選項:
| 選項 | 說明 |
|---|---|
-n, --publisherDisplayName |
發行者顯示名稱 |
--package |
同時封裝專案 |
--publish |
封裝並發佈(隱含 --package) |
-f, --flightId |
發佈到特定測試群組 |
-prp, --packageRolloutPercentage |
逐步推出百分比 (0-100) |
-a, --arch |
架構:x86、x64、arm64 |
-o, --output |
套件的輸出目錄 |
-ver, --version |
建置時使用的版本 |
支援的專案類型:
- Windows App SDK / WinUI 3
- UWP
- .NET MAUI
- Flutter
- Electron
- React Native for Desktop
- PWA(漸進式網頁應用程式)
範例:
# 初始化 WinUI 專案
msstore init ./my-winui-app
# 初始化 PWA
msstore init https://contoso.com --output ./pwa-package
# 初始化並發佈
msstore init ./my-app --publish
package - 封裝以提交到 Store
封裝應用程式以提交到 Microsoft Store。
msstore package <pathOrUrl> [options]
引數:
| 引數 | 說明 |
|---|---|
pathOrUrl |
專案目錄路徑或 PWA URL |
選項:
| 選項 | 說明 |
|---|---|
-o, --output |
套件的輸出目錄 |
-a, --arch |
架構:x86、x64、arm64 |
-ver, --version |
套件的版本 |
範例:
# 封裝預設架構
msstore package ./my-app
# 封裝多種架構
msstore package ./my-app --arch x64,arm64 --output ./packages
# 封裝並指定版本
msstore package ./my-app --version 1.2.3.0
publish - 發佈到 Store
將應用程式發佈到 Microsoft Store。
msstore publish <pathOrUrl> [options]
引數:
| 引數 | 說明 |
|---|---|
pathOrUrl |
專案目錄路徑或 PWA URL |
選項:
| 選項 | 說明 |
|---|---|
-i, --inputFile |
現有 .msix 或 .msixupload 檔案的路徑 |
-id, --appId |
應用程式識別碼(如果尚未初始化) |
-nc, --noCommit |
將提交保留為草稿狀態 |
-f, --flightId |
發佈到特定測試群組 |
-prp, --packageRolloutPercentage |
逐步推出百分比 (0-100) |
範例:
# 發佈專案
msstore publish ./my-app
# 發佈現有套件
msstore publish ./my-app --inputFile ./packages/MyApp.msixupload
# 以草稿形式發佈
msstore publish ./my-app --noCommit
# 逐步推出發佈
msstore publish ./my-app --packageRolloutPercentage 10
flights - 套件測試群組管理
管理套件測試群組(Beta 測試群組)。
| 子命令 | 說明 |
|---|---|
list |
列出應用程式的所有測試群組 |
get |
取得測試群組詳細資料 |
delete |
刪除測試群組 |
create |
建立新的測試群組 |
submission |
管理測試群組提交 |
列出測試群組
msstore flights list <productId>
取得測試群組詳細資料
msstore flights get <productId> <flightId>
建立測試群組
msstore flights create <productId> <friendlyName> --group-ids <group-ids>
選項:
| 選項 | 說明 |
|---|---|
-g, --group-ids |
測試群組識別碼(逗號分隔) |
-r, --rank-higher-than |
要排名更高的測試群組識別碼 |
刪除測試群組
msstore flights delete <productId> <flightId>
測試群組提交
# 取得測試群組提交
msstore flights submission get <productId> <flightId>
# 發佈測試群組提交
msstore flights submission publish <productId> <flightId>
# 檢查測試群組提交狀態
msstore flights submission status <productId> <flightId>
# 輪詢測試群組提交
msstore flights submission poll <productId> <flightId>
# 刪除測試群組提交
msstore flights submission delete <productId> <flightId>
測試群組推出管理
# 取得推出狀態
msstore flights submission rollout get <productId> <flightId>
# 更新推出百分比
msstore flights submission rollout update <productId> <flightId> <percentage>
# 暫停推出
msstore flights submission rollout halt <productId> <flightId>
# 完成推出 (100%)
msstore flights submission rollout finalize <productId> <flightId>
常見工作流程
工作流程 1:首次 Store 設定
# 1. 安裝 CLI
winget install "Microsoft Store Developer CLI"
# 2. 設定認證(從合作夥伴中心取得)
msstore reconfigure --tenantId $TENANT_ID --sellerId $SELLER_ID --clientId $CLIENT_ID --clientSecret $CLIENT_SECRET
# 3. 驗證設定
msstore info
# 4. 列出應用程式以確認存取權限
msstore apps list
工作流程 2:初始化並發佈新應用程式
# 1. 導覽至專案
cd my-winui-app
# 2. 初始化以發佈到 Store(建立/更新應用程式身分)
msstore init .
# 3. 封裝應用程式
msstore package . --arch x64,arm64
# 4. 發佈到 Store
msstore publish .
# 5. 檢查提交狀態
msstore submission status <productId>
工作流程 3:更新現有應用程式
# 1. 建置更新後的應用程式
dotnet publish -c Release
# 2. 封裝並發佈
msstore publish ./my-app
# 或從現有套件發佈
msstore publish ./my-app --inputFile ./artifacts/MyApp.msixupload
工作流程 4:逐步推出
# 1. 以初始推出百分比發佈
msstore publish ./my-app --packageRolloutPercentage 10
# 2. 監控並增加推出比例
msstore submission poll <productId>
# 3. (驗證後)完成至 100%
# 透過合作夥伴中心或提交更新完成
工作流程 5:使用測試群組進行 Beta 測試
# 1. 先在合作夥伴中心建立測試群組
# 然後建立測試群組
msstore flights create <productId> "Beta 測試者" --group-ids "group-id-1,group-id-2"
# 2. 發佈到測試群組
msstore publish ./my-app --flightId <flightId>
# 3. 檢查測試群組提交狀態
msstore flights submission status <productId> <flightId>
# 4. 測試完成後,發佈到正式環境
msstore publish ./my-app
工作流程 6:CI/CD 管線整合
# GitHub Actions 範例
name: 發佈到 Store
on:
release:
types: [published]
jobs:
publish:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
- name: 設定 .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: 安裝 msstore CLI
run: winget install "Microsoft Store Developer CLI" --accept-package-agreements --accept-source-agreements
- name: 設定 Store 認證
run: |
msstore reconfigure --tenantId ${{ secrets.TENANT_ID }} --sellerId ${{ secrets.SELLER_ID }} --clientId ${{ secrets.CLIENT_ID }} --clientSecret ${{ secrets.CLIENT_SECRET }}
- name: 建置應用程式
run: dotnet publish -c Release
- name: 發佈到 Store
run: msstore publish ./src/MyApp
與 winapp CLI 整合
winapp CLI (v0.2.0+) 透過 winapp store 子命令與 msstore 整合:
# 以下命令等效:
msstore reconfigure --tenantId xxx --clientId xxx --clientSecret xxx
winapp store reconfigure --tenantId xxx --clientId xxx --clientSecret xxx
# 列出應用程式
msstore apps list
winapp store apps list
# 發佈
msstore publish ./my-app
winapp store publish ./my-app
當您想要統一的 CLI 體驗來進行封裝和發佈時,請使用 winapp store。
疑難排解
| 問題 | 解決方案 |
|---|---|
| 驗證失敗 | 使用 msstore info 驗證認證;重新執行 msstore reconfigure |
| 找不到應用程式 | 確認產品識別碼是否正確;執行 msstore apps list 驗證 |
| 權限不足 | 檢查合作夥伴中心中的 Azure AD 應用程式角色(需要管理員或開發人員) |
| 套件驗證失敗 | 確保套件符合 Store 需求;檢查合作夥伴中心以取得詳細資訊 |
| 提交卡住 | 執行 msstore submission poll <productId> 檢查狀態 |
| 找不到測試群組 | 使用 msstore flights list <productId> 驗證測試群組識別碼 |
| 推出百分比無效 | 值必須介於 0 到 100 之間 |
| PWA 初始化失敗 | 確保 URL 可公開存取且具有有效的網頁應用程式資訊清單 |
環境變數
CLI 支援用於認證的環境變數:
| 變數 | 說明 |
|---|---|
MSSTORE_TENANT_ID |
Azure AD 租用戶識別碼 |
MSSTORE_SELLER_ID |
合作夥伴中心賣家識別碼 |
MSSTORE_CLIENT_ID |
Azure AD 應用程式用戶端識別碼 |
MSSTORE_CLIENT_SECRET |
用戶端密碼 |






