建構和釋出為 Windows 應用
釋出 Windows 桌面應用程式的便捷方法是將其釋出至 微軟應用商店,本指南提供了將 Flutter 應用釋出到 微軟應用商店 的分步操作指南。
預先準備
在開始釋出 Flutter Windows 桌面應用程式之前,有必要確認你的應用滿足 微軟應用商店政策。
提交應用前加入 微軟合作伙伴網路 也是必要的。
在合作伙伴中心申請應用
在 微軟合作伙伴中心 中管理一個應用程式的生命週期。
首先,有必要預約應用名稱,並且確定有使用這個名稱的權利。一旦名稱確定可用,則該應用程式將可以提供推送通知等服務,並且可以開始新增擴充功能。
類似於價格、可用性、年齡等級和類別等選項必須在第一次提交時一併配置,這些選項在後續提交時將自動保留。
打包並部署
應用程式釋出到微軟商店前必須要打套件。有效的格式是 .msix、.msixbundle、.msixupload、.appx、 .appxbundle、.appxupload 和 .xap。
手動打套件和部署
檢視 MSIX 打包,學習如何打包 Flutter Windows 桌面應用程式。
請注意,每個產品都有一個唯一的 ID,這是應用商店分配的。
如果應用包是手動建構的,在打包過程中必須手動新增 ID 詳情。這些基本資訊可以從合作伙伴中心檢索到。
-
在合作伙伴中心中,導航到應用程式。
-
選擇 Product management。
-
點選 Product identity,檢查應用套件的 ID,釋出者,釋出者的顯示名稱。
在手動打包應用程式後,還需要手動提交應用程式包到 微軟合作伙伴中心。這個步驟可以透過建立新的提交來完成,導航到 Packages,並上傳建立的應用程式套件。
持續部署
除了手動建立和部署軟體包外,在第一次提交應用程式到微軟商店後,還可以使用持續整合/持續部署 (CI/CD) 工具自動化建構、打包、版本管理、和部署應用程式。
Codemagic 持續整合/持續部署 (CI/CD)
Codemagic 持續整合/持續部署 (CI/CD)
使用 Pub 上的 msix
package
來打包 Flutter Windows 桌面應用程式。
對於 Flutter 應用程式,無論是 Codemagic Workflow Editor 還是 codemagic.yaml 都可以用來打包應用程式並部署到微軟合作伙伴中心。其他選項(如軟體套件中包含的功能列表和語言資源)可以使用上述的軟體套件進行配置。
對於釋出應用來說,Codemagic 使用 合作伙伴中心提交 API;因此,Codemagic 需要 關聯 Azure Active Directory 和合作夥伴中心賬戶。
更新應用程式的版本號
對於釋出到 Microsoft Store 的 Flutter 桌面版應用,版本號必須在打包過程中設定,而不能透過
pubspec.yaml
或命令列引數設定。
預設的應用版本號為 1.0.0.0
。
For apps not published to the Microsoft Store, you
can set the app’s executable’s file and product versions.
The executable’s default file version is 1.0.0.1
,
and its default product version is 1.0.0+1
. To update these,
navigate to the pubspec.yaml
file and update the
following line:
version: 1.0.0+1
The build name is three numbers separated by dots,
followed by an optional build number that is separated
by a +
. In the example above, the build name is 1.0.0
and the build number is 1
.
The build name becomes the first three numbers of the file and product versions, while the build number becomes the fourth number of the file and product versions.
Both the build name and number can be overridden in
flutter build windows
by specifying --build-name
and
--build-number
, respectively.
新增應用圖示
在打包前更新 Flutter Windows 桌面應用程式的圖示:
-
導航到 Flutter 專案中的 windows\runner\resources 目錄。
-
替換 app_icon.ico 為想要的圖示。
-
如果圖示檔案的名稱不是 app_icon.ico,請將 windows\runner\Runner.rc 檔案中的 IDI_APP_ICON 值指向新的路徑。
在使用 msix
pub package 打套件時,可以在 pubspec.yaml
檔案中配置 logo 路徑。
要更新商店列表中的應用程式圖示,請導航到提交的商店列表並選擇商店 logo。在那裡可以上傳尺寸為 300 x 300 畫素的圖片。
所有上傳的圖片將被保留,以便於以後提交使用。
驗證應用程式包
在釋出到微軟商店之前,建議先在本地驗證應用程式套件。
Windows 應用認證工具套件 是一個包含在 Windows 軟體開發工具套件(SDK)中的工具。
驗證應用程式:
-
啟動 Windows 應用認證工具套件。
-
選擇 Flutter Windows 桌面應用程式套件(.msix、.msixbundle 等)。
-
選擇測試報告的輸出目錄。
即使認證透過,報告也可能包含重要警告和資訊。