跳到主要内容

将你的 Napacitor Windows 应用部署到 Microsoft Store

Napacitor 应用可以发布到 Windows——这是 Capacitor 工作流不具备的能力。MAUI 宿主构建出 Windows 桌面应用,商店就绪的分发格式是 MSIX。本页介绍打包、签名和 Microsoft Store 提交。

MSIX vs. 非打包模式​

生成的宿主默认使用非打包模式(WindowsPackageType=None),这是本地迭代最快的方式。分发时切换到 MSIX:

<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
<WindowsPackageType>MSIX</WindowsPackageType>
</PropertyGroup>

打包与非打包模式的取舍见 MAUI Windows 部署概览。

用 dotnet publish 打包​

npx nap sync
dotnet publish maui/App.csproj -f net10.0-windows10.0.19041.0 -c Release -p:WindowsPackageType=MSIX

.msix 包写入 maui/bin/Release/net10.0-windows10.0.19041.0/win10-x64/AppPackages/。MSIX 打包需要在 App.csproj 中设置几个身份属性——一次性设置即可(只有 Publisher 是严格必需的):

<PropertyGroup Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">
<WindowsPackageType>MSIX</WindowsPackageType>
<Publisher>CN=Contoso Software, O=Contoso Software, C=US</Publisher>
<PublisherDisplayName>Contoso Software</PublisherDisplayName>
<Version>1.0.0.0</Version>
<ApplicationTitle>My App</ApplicationTitle>
</PropertyGroup>

所有可用选项见 用 CLI 发布打包的 .NET MAUI Windows 应用。

签名​

MSIX 包必须签名才能安装。

  • 侧载(sideloading):创建自签名证书,在目标机器的 Trusted People/Trusted Root 中安装它,然后为包签名(dotnet publish 可以用 -p:PackageCertificateThumbprint=… 签名)。见 MSIX 打包文档。
  • 商店发布:不要手动签名。Partner Center 代码签名会在提交过程中为你的包签名。

提交到 Microsoft Store​

  1. 构建已签名(或未签名,交给商店签名)的 .msix 包;
  2. 在 Partner Center 中创建应用;
  3. 上传包、填写商店条目,并完成认证检查。

完整流程见 Windows 应用文档中的 将应用发布到 Microsoft Store。

注意:商店提交和认证在 Windows 上进行;与 App Store 不同,没有 macOS 或 Xcode 要求。