构建和发布为 Windows 应用

本指南提供了将 Flutter 应用发布到 微软应用商店 的分步操作指南。

This guide provides a step-by-step walkthrough of releasing a Flutter app to the Microsoft Store.



在开始发布 Flutter Windows 桌面应用程序之前,有必要确认你的应用满足 微软应用商店政策

Before beginning the process of releasing a Flutter Windows Desktop app, it is necessary to confirm that it satisfies Microsoft Store Policies.

加入 微软合作伙伴网络 也是必要的。

Joining the Microsoft Partner Network is also required.


Set up your application in the Partner Center

微软合作伙伴中心 中管理一个应用程序的生命周期。

Manage an application’s life cycle in the Microsoft Partner Center.


First off, it is necessary to reserve the application name and ensure that the required rights to the name exist. Once the name is reserved, the application will be provisioned for services such as push notifications, and it is possible to start adding add-ons.


Options such as pricing, availability, age ratings, and category have to be configured together with the first submission and are automatically retained for the subsequent submissions.


Packaging and deployment

应用程序发布到微软商店前必须要打包。有效的格式是 .msix.msixbundle.msixupload.appx.appxbundle.appxupload.xap

In order to publish an application to Microsoft Store, it first has to be packaged. The valid formats are .msix, .msixbundle, .msixupload, .appx, .appxbundle, .appxupload, and .xap.


Manual packaging and deployment

查看 MSIX 打包,学习如何打包 Flutter Windows 桌面应用程序。

Check out MSIX packaging to learn about packaging Flutter Windows Desktop applications.

请注意,每个产品都有一个唯一的 ID,这是应用商店分配的。

Note that each product has a unique identity, which the Store assigns.

如果应用包是手动构建的,在打包过程中必须手动添加 ID 详情。这些基本信息可以从合作伙伴中心检索到。

If the package is being built manually, it is necessary to include its identity details manually during the packaging. The essential information can be retrieved from the Partner Center:

  1. 在合作伙伴中心中,导航到应用程序。

    Navigate to the application in the Partner Center.

  2. 选择 Product management

    Select Product management.

  3. 点击 Product identity,检查应用包的 ID,发布者,发布者的显示名称。

    Retrieve the package identity name, publisher, and publisher display name by clicking on Product identity.

在手动打包应用程序后,还需要手动提交应用程序包到 微软合作伙伴中心。这个步骤可以通过创建新的提交来完成,导航到 Packages,并上传创建的应用程序包。

After manually packaging the application, it will also have to be manually submitted to the Microsoft Partner Center. This can be done by creating a new submission, navigating to Packages, and uploading the created application package.


Continuous deployment

除了手动创建和部署软件包外,在第一次提交应用程序到微软商店后,还可以使用持续集成/持续部署 (CI/CD) 工具自动化构建、打包、版本管理、和部署应用程序。

In addition to manually creating and deploying the package, it is possible to automate the build, package, versioning, and deployment process using CI/CD tooling after having submitted the application to the Microsoft Store for the first time.

Codemagic 持续集成/持续部署 (CI/CD)

Codemagic CI/CD

Codemagic 持续集成/持续部署 (CI/CD) 使用 Pub 上的 msix package 来打包 Flutter Windows 桌面应用程序。

Codemagic CI/CD uses the msix pub package to package Flutter Windows Desktop applications.

对于 Flutter 应用程序,无论是 Codemagic Workflow Editor 还是 codemagic.yaml 都可以用来打包应用程序并部署到微软合作伙伴中心。其他选项(如软件包中包含的功能列表和语言资源)可以使用上述的软件包进行配置。

For Flutter applications, either the Codemagic Workflow Editor or codemagic.yaml can be used to package the application and deploy to Microsoft Partner Center. Additional options (such as the list of capabilites and language resources contained in the package) can be configured using the aforementioned package.

对于发布应用来说,Codemagic 使用 合作伙伴中心提交 API;因此,Codemagic 需要 关联 Azure Active Directory 和合作伙伴中心账户

For publishing, Codemagic uses the Partner Center submission API; thus, Codemagic requires associating the Azure Active Directory and Partner Center accounts.


Updating the app’s version number

对于 Flutter Windows 桌面版来说,版本号必须在打包过程中设置,不能通过 pubspec.yaml 或命令行参数设置。

With Flutter Windows Desktop, the version number must be set during the packaging process and can not be set via the pubspec.yaml or command line arguments.


The default version number of the app is

请注意,应用程序不允许有一个修订版本号(第四段)不为零的版本。因此,在所有的版本中,版本的最后一个数字必须保持为零。请注意遵循微软的 版本指南

Note that applications are not allowed to have a Version with a revision number other than zero. Thus, the last number of the version must remain zero for all releases. Take note to follow Microsoft’s versioning guidelines.


Add app icons

在打包前更新 Flutter Windows 桌面应用程序的图标:

To update the icon of a Flutter Windows Desktop application before packaging:

  1. 导航到 Flutter 项目中的 windows\runner\resources 目录。

    Navigate to windows\runner\resources in the Flutter project.

  2. 替换 app_icon.ico 为想要的图标。

    Replace the app_icon.ico with the wanted icon.

  3. 如果图标文件的名称不是 app_icon.ico,请将 windows\runner\Runner.rc 文件中的 IDI_APP_ICON 值指向新的路径。

    If the name of the icon is other than app_icon.ico, proceed to change the IDI_APP_ICON value in the windows\runner\Runner.rc file to point to the new path.

在使用 msix pub package 打包时,可以在 pubspec.yaml 文件中配置 logo 路径。

When packaging with the msix pub package, the logo path can also be configured inside the pubspec.yaml file.

要更新商店列表中的应用程序图标,请导航到提交的商店列表并选择商店 logo。在那里可以上传尺寸为 300 x 300 像素的图片。

To update the application image in the Store listing, navigate to the Store listing step of the submission and select Store logos. There it is possible to upload the logo with the size of 300 x 300 pixels.


All uploaded images are retained for subsequent submissions.


Validating the application package


Before publication to the Microsoft Store, validating the application package locally first is recommended.

Windows 应用认证工具包 是一个包含在 Windows 软件开发工具包(SDK)中的工具。

Windows App Certification Kit is a tool that is included in the Windows Software Development Kit (SDK).


To validate the application:

  1. 启动 Windows 应用认证工具包。

    Launch Windows App Cert Kit.

  2. 选择 Flutter Windows 桌面应用程序包(.msix.msixbundle 等)。

    Select the Flutter Windows Desktop package (.msix, .msixbundle etc).

  3. 选择测试报告的输出目录。

    Choose a destination for the test report.


The report may contain important warnings and information, even if the certification passes.