@choochmeque/tauri-windows-bundle

中文文档
0.2.0发布于 2026/09/16MITTypeScriptES Module构建来源已验证近 30 天下载 9941

Tauri 应用程序的 MSIX 包装工具 - Windows 存储已准备好的捆绑

中文使用文档
文档目录32 节
  1. 特征
  2. 先决条件
  3. 捆绑 msixbundle-cli
  4. 安装
  5. 使用量
  6. 初始化
  7. 配置
  8. 构建
  9. 产出
  10. CLI 参考
  11. 窗口扩展
  12. 文件关联
  13. 协议处理器
  14. 共享目标
  15. 启动任务
  16. 背景菜单
  17. 背景任务
  18. 列表扩展
  19. 应用程序执行别名
  20. 应用服务
  21. 敬酒活动
  22. 自动播放
  23. 打印任务设置
  24. 缩略图处理器
  25. 预览处理器
  26. 列表扩展
  27. 删除扩展
  28. 代码签名
  29. 备选案文1:PFX证书
  30. 选项2: Windows 证书存储
  31. GitHub 动作
  32. 许可证

圆窗

npm codecov License

Tauri apps 的 MSIX 包装工具 - 创建 Windows Store 即时捆绑,并有多存档支持.

特征

  • MSIX 包装 - 创建存储准备的MSIX软件包
  • 多结构支持 - 为x64和arm64建造一捆
  • tauri.conf.json (法语) 一体化 - 自动读取应用程序名称、版本、图标和资源
  • 代码签名 - 支持PFX证书和Windows证书商店
  • 资源索引 - 可选 resources.pri 创造合格资产
  • 窗口扩展 - 共享目标、文件协会、协议处理器、启动任务、背景菜单、背景任务、应用程序执行外号、App服务、Toast激活、自动播放、打印任务设置、缩略图/预览处理器

先决条件

  • 锈 有 Windows 目标
  • Windows SDK (用于签名)
# Install Rust targets for multiarch builds
rustup target add x86_64-pc-windows-msvc
rustup target add aarch64-pc-windows-msvc

捆绑 msixbundle-cli

在 Windows(x64和arm64)上 msixbundle-cli 二进制自动被运出 optionalDependencies 侧车(@choochmeque/msixbundle-cli-win32)——不需要单独安装.

如果您在 macOS 或 Linux (例如交叉编译) 上, 或者您安装了 --omit=optional (无)/ --no-optional (pnpm/yarn),建设命令会回到任何 msixbundle-cli 交给你了 PATH 并提示 cargo install msixbundle-cli 如果它不见了.

安装

# One-time setup (use @latest to ensure newest version)
npx @choochmeque/tauri-windows-bundle@latest init

# Or install as dev dependency
npm install -D @choochmeque/tauri-windows-bundle

提示 : 使用 @latest 以 npx 绕过缓存版本 : npx @choochmeque/tauri-windows-bundle@latest --version

使用量

初始化

npx @choochmeque/tauri-windows-bundle init

这就产生了:

  • src-tauri/gen/windows/bundle.config.json - MSIX组合
  • src-tauri/gen/windows/AppxManifest.xml.template - 突出模板
  • src-tauri/gen/windows/Assets/ - 图标(从 src-tauri/icons/ 或占位符)
  • 添加数 @choochmeque/tauri-windows-bundle 作为依赖性
  • 添加数 tauri:windows:build 脚本到 package.json

说明: 如果 Tauri 图标存在于 src-tauri/icons/,自动复制。 宽瓦(310x150)由以正方形图标为中心而产生.

特定窗口图标 : 设定 bundle.icon 内 tauri.windows.conf.json (或 tauri.conf.json指向不同的文件夹,以及 init 将由此获得资产来源。 例如,与

// tauri.windows.conf.json
{ "bundle": { "icon": ["icons/windows/32x32.png", "icons/windows/icon.ico"] } }

init 用途 src-tauri/icons/windows/ (第一个目录的父目录) .png 条目,已解决 src-tauri/作为资产来源。 在该文件夹内,它寻找由MSIX命名的文件 Tauri通过 tauri icon数字 :

  • 直接副本 : StoreLogo.png, (中文(简体) ), Square44x44Logo.png, (中文(简体) ), Square150x150Logo.png (每个缺失的文件成为占位符).
  • 宽瓦 (Wide310x150Logo.png)是从找到的第一个平方图标生成的: Square150x150Logo.png → Square142x142Logo.png → icon.png → 128x128.png。 。 。 .
  • 备选案文来源(当 --scale 编号 : --target-size 编号 : --unplated 编号 : --light-unplated 已设定 : icon.png → Square310x310Logo.png → 128x128.png。 。 。 .

若为 bundle.icon 没有 .png 条目,默认值 src-tauri/icons/ 已使用.

图标变体( 可选)

将一面或多面旗帜传给 init 还生成后缀资产变体 Windows 用于 DPI 缩放、任务栏/启动图标和主题意识牌:

npx @choochmeque/tauri-windows-bundle init --all-variants
旗帜生成的文件
--scale<asset>.scale-100/125/150/200/400.png 用于 StoreLogo,平方44x44Logo,平方150x150Logo
--target-sizeSquare44x44Logo.targetsize-16/20/24/30/32/36/40/48/60/64/72/80/96/256.png (任务栏,启动列表,跳出列表)
--unplatedSquare44x44Logo.targetsize-N_altform-unplated.png (透明背景)
--light-unplatedSquare44x44Logo.targetsize-N_altform-lightunplated.png (轻主题)
--all-variants以上所有情况

变体来源于找到的最高分辨率 Tauri 图标, 依此顺序 : src-tauri/icons/icon.png → Square310x310Logo.png → 128x128.png如果不存在,则用警告跳过变量生成.

传出任何变种旗也翻转 resourceIndex.enabled 改为 true 在生成时 bundle.config.json,因为Windows只通过一个 resources.pri 文件构建于 --makepri。 。 。 .

配置

编辑 src-tauri/gen/windows/bundle.config.json数字 :

{
  "publisher": "CN=YourCompany",
  "publisherDisplayName": "Your Company Name",
  "capabilities": {
    "general": ["internetClient"]
  },
  "signing": {
    "pfx": null,
    "pfxPassword": null
  },
  "resourceIndex": {
    "enabled": false,
    "keepConfig": false
  }
}

executableName (可选的) 当生成错误时, 将 exe 文件名 。 没有它,名字就决定从 mainBinaryName 在touri.conf.json, 然后第一个 [[bin]] (次数) [package]src-touri/cargo.toml中的名称,并仅作为产品名称的最后手段.

publisher 财务报告和审定财务报表 publisherDisplayName 可选在 bundle.config.json。如果省略, publisher 倒计时 bundle.publisher 从 tauri.conf.json 或者说 tauri.windows.conf.json如果 publisherDisplayName ,默认为已解决 publisher 数值.

能力 在构建时验证。 支持三种类型:

{
  "capabilities": {
    "general": ["internetClient", "internetClientServer", "privateNetworkClientServer"],
    "device": ["webcam", "microphone", "location", "bluetooth"],
    "restricted": ["broadFileSystemAccess", "allowElevation"]
  }
}
  • general - 标准能力<Capability>(中文(简体) )
  • device - 设备接入(<DeviceCapability>(中文(简体) )
  • restricted - 需要储存批准(<rescap:Capability>(中文(简体) )

说明: runFullTrust 总是自动添加( Tauri apps 需要).

resourceIndex.enabled 生成 resources.pri 通过 msixbundle-cli --makepri 在包装之前。 在使用合格资产时启用此功能( 例如, 比例表特定标志例如 Square44x44Logo.scale-200.png) (中文(简体) ).

resourceIndex.keepConfig 继续生成 priconfig.xml 每个 AppxContent 调试目录 .

自动读取自 Tauri.conf.json / Tauri.windows.conf.json:

  • displayName ← productName
  • version ← version (自动转换为4个部分: 1.0.0 → 1.0.0.0(中文(简体) )
  • description ← bundle.shortDescription
  • publisher ← bundle.publisher (没有被捆绑时倒回. config.json)
  • icons ← bundle.icon
  • resources ← bundle.resources (阵列条目保持其布局;领导) ../ 地图到 _up_/ 和绝对根到 _root_/,匹配 Tauri 的位置 resolveResource() 查看运行时间 )
  • externalBin ← bundle.externalBin (旁车在前身旁边摆出) -<target-triple> 后缀已剥去; 缺少一条已宣布的侧车失效 )
  • signing ← bundle.windows.certificateThumbprint

特定平台配置 : 数值 tauri.windows.conf.json 覆盖 tauri.conf.json 使用 JSON 合并补丁(RFC 7396)中定义 Windows 特定设置 identifier, (中文(简体) ), productName,或 bundle.publisher 分别.

构建

# Build x64 only (default, uses cargo, release mode)
pnpm tauri:windows:build

# Build multiarch bundle (x64 + arm64)
pnpm tauri:windows:build --arch x64,arm64

# Debug build (release is default)
pnpm tauri:windows:build --debug

# Use different build runner (pnpm, npm, yarn, bun, etc.)
pnpm tauri:windows:build --runner pnpm
pnpm tauri:windows:build --runner npm

# Re-derive Assets/ from bundle.icon (overwrites manual edits in
# src-tauri/gen/windows/Assets/). Variant flags configured at init are
# replayed from bundle.config.json's `assets.variants`.
pnpm tauri:windows:build --regenerate-assets

默认 build 复制任何内容 src-tauri/gen/windows/Assets/ 手工编辑的平板木板图标 横跨建筑 过 --regenerate-assets 从图标文件夹中刷新此目录 bundle.icon (相同的逻辑) init (a) 使用.

产出

target/msix/
├── MyApp_x64.msix
├── MyApp_arm64.msix      # if --arch x64,arm64
└── MyApp.msixbundle      # combined bundle

CLI 参考

npx @choochmeque/tauri-windows-bundle init [options]
  -p, --path <path>    Path to Tauri project
  --scale              Generate .scale-100/125/150/200/400 PNG variants
  --target-size        Generate .targetsize-16/20/24/30/32/36/40/48/60/64/72/80/96/256 PNG variants for Square44x44Logo
  --unplated           Generate _altform-unplated targetsize variants
  --light-unplated     Generate _altform-lightunplated targetsize variants
  --all-variants       Shortcut for all four variant families above

npx @choochmeque/tauri-windows-bundle build [options]
  --arch <archs>        Architectures (comma-separated: x64,arm64) [default: x64]
  --debug               Build in debug mode (release is default)
  --min-windows <ver>   Minimum Windows version [default: 10.0.17763.0]
  --runner <runner>     Build runner (cargo, pnpm, npm, yarn, bun) [default: cargo]
  --verbose             Show full build output instead of spinner
  --regenerate-assets   Regenerate gen/windows/Assets/ from bundle.icon
                        (overwrites manual edits)

npx @choochmeque/tauri-windows-bundle extension list
  -p, --path <path>    Path to Tauri project

npx @choochmeque/tauri-windows-bundle extension add <type>
  <type>               Extension type (see below)
  -p, --path <path>    Path to Tauri project

npx @choochmeque/tauri-windows-bundle extension remove <type> [name]
  <type>               Extension type (see below)
  [name]               Extension identifier (required for most types)
  -p, --path <path>    Path to Tauri project

Extension types:
  file-association     Associate file types with your app
  protocol             Register URL protocol handlers (myapp://)
  share-target         Receive shared content from other apps
  startup-task         Run app on Windows login
  context-menu         Add right-click menu items in Explorer
  background-task      Run tasks when app is not in foreground
  app-execution-alias  Run app from command line (e.g., myapp)
  app-service          Allow other apps to call into your app
  toast-activation     Handle toast notification clicks
  autoplay             Launch when media/device is inserted
  print-task-settings  Custom print settings UI
  thumbnail-handler    Custom file thumbnails in Explorer
  preview-handler      Custom file previews in Explorer

窗口扩展

文件关联

npx @choochmeque/tauri-windows-bundle extension add file-association
# Prompts for: name, extensions, description

或者,在 tauri.conf.json 根据标准 bundle.fileAssociations 键,并在构建时自动取出 :

{
  "bundle": {
    "fileAssociations": [
      { "ext": ["ics"], "name": "iCalendar", "description": "iCalendar event file" },
    ],
  },
}

bundle.config.json 条目在顶部合并,在名称相撞时获胜,所以 已存在的仅Windows的覆盖继续工作.

协议处理器

npx @choochmeque/tauri-windows-bundle extension add protocol
# Prompts for: protocol name, display name

共享目标

# Enable
npx @choochmeque/tauri-windows-bundle extension add share-target

# Disable
npx @choochmeque/tauri-windows-bundle extension remove share-target

启动任务

在 Windows 启动时自动运行您的应用程序 .

# Enable
npx @choochmeque/tauri-windows-bundle extension add startup-task

# Disable
npx @choochmeque/tauri-windows-bundle extension remove startup-task

背景菜单

在 Windows 浏览器中添加右键菜单项 .

npx @choochmeque/tauri-windows-bundle extension add context-menu
# Prompts for: menu name, file types, display name

背景任务

应用程序不在前景时运行任务 .

npx @choochmeque/tauri-windows-bundle extension add background-task
# Prompts for: task name, type (timer/systemEvent/pushNotification)

列表扩展

npx @choochmeque/tauri-windows-bundle extension list

应用程序执行别名

从命令行运行您的应用( 例如 ), myapp 而不是整个路径.

npx @choochmeque/tauri-windows-bundle extension add app-execution-alias
# Prompts for: alias name

应用服务

允许其他应用程序调用您的应用程序 .

npx @choochmeque/tauri-windows-bundle extension add app-service
# Prompts for: service name

敬酒活动

处理土司通知点击和行动,包括应用程序退出后从行动中心启动的冷启动.

# Enable
npx @choochmeque/tauri-windows-bundle extension add toast-activation
# Prompts for: CLSID (leave empty to auto-generate from app identifier)

# Disable
npx @choochmeque/tauri-windows-bundle extension remove toast-activation

表示两个 com:Extension Category="windows.comServer" (所以Windows知道在激活时要发射的exe)和 desktop:Extension Category="windows.toastNotificationActivation" (将土司点击CLSID).

自动播放

插入媒体或设备时启动您的应用程序 .

npx @choochmeque/tauri-windows-bundle extension add autoplay
# Prompts for: verb, action display name, event type (content/device)

打印任务设置

添加自定义打印设置 UI.

# Enable
npx @choochmeque/tauri-windows-bundle extension add print-task-settings

# Disable
npx @choochmeque/tauri-windows-bundle extension remove print-task-settings

缩略图处理器

在 Explorer 为您的文件类型提供自定义缩略图 .

npx @choochmeque/tauri-windows-bundle extension add thumbnail-handler
# Prompts for: CLSID, file types

预览处理器

在 Explorer 中提供自定义文件预览 .

npx @choochmeque/tauri-windows-bundle extension add preview-handler
# Prompts for: CLSID, file types

列表扩展

npx @choochmeque/tauri-windows-bundle extension list

删除扩展

npx @choochmeque/tauri-windows-bundle extension remove file-association myfiles
npx @choochmeque/tauri-windows-bundle extension remove protocol myapp
npx @choochmeque/tauri-windows-bundle extension remove context-menu open-with-myapp
npx @choochmeque/tauri-windows-bundle extension remove background-task sync-task
npx @choochmeque/tauri-windows-bundle extension remove app-execution-alias myapp
npx @choochmeque/tauri-windows-bundle extension remove app-service com.myapp.service
npx @choochmeque/tauri-windows-bundle extension remove autoplay open

代码签名

备选案文1:PFX证书

{
  "signing": {
    "pfx": "path/to/certificate.pfx",
    "pfxPassword": null
  }
}

通过环境变量设置密码 :

export MSIX_PFX_PASSWORD=your-password

选项2: Windows 证书存储

使用从 tauri.conf.json数字 :

{
  "bundle": {
    "windows": {
      "certificateThumbprint": "ABC123..."
    }
  }
}

GitHub 动作

自动化MSIX构建的示例工作流程.

说明: 运行 npx @choochmeque/tauri-windows-bundle@latest init 本地端首先生成所需的配置文件,然后将其输入您的仓库.

name: Build Windows MSIX

on:
  push:
    tags:
      - 'v*'
  workflow_dispatch:

jobs:
  build:
    runs-on: windows-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup pnpm
        uses: pnpm/action-setup@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20'
          cache: 'pnpm'

      - name: Setup Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: x86_64-pc-windows-msvc, aarch64-pc-windows-msvc

      # Caches the cargo registry and build artifacts; cuts warm build times
      # to a fraction of the cold ones.
      - name: Cache Rust
        uses: Swatinem/rust-cache@v2
        with:
          workspaces: src-tauri

      - name: Install dependencies
        run: pnpm install

      # On Windows runners the @choochmeque/msixbundle-cli-win32 sidecar is
      # installed automatically via optionalDependencies. On non-Windows runners
      # (or with --no-optional) install it explicitly:
      #   - run: cargo install msixbundle-cli

      - name: Build MSIX bundle
        run: pnpm tauri:windows:build --arch x64,arm64 --runner pnpm

      - name: Upload artifacts
        uses: actions/upload-artifact@v4
        with:
          name: msix-bundle
          path: src-tauri/target/msix/*.msixbundle

输出将在 src-tauri/target/msix/YourApp.msixbundle。 。 。 .

许可证

麻省理工学院

版本与发布记录

@choochmeque/tauri-windows-bundle 共发布 30 个版本,首次发布于 2026/01/02;过去 12 个月发布了 30 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.2.0latest2026/09/161 个月前
0.1.292026/09/012 个月前
0.1.282026/07/014 个月前
0.1.272026/06/304 个月前
0.1.262026/06/234 个月前
0.1.252026/06/194 个月前

关于 @choochmeque/tauri-windows-bundle 的常见问题

@choochmeque/tauri-windows-bundle 是什么?

Tauri 应用程序的 MSIX 包装工具 - Windows 存储已准备好的捆绑

如何安装 @choochmeque/tauri-windows-bundle?

在项目目录运行 npm install @choochmeque/tauri-windows-bundle,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 tauri-windows-bundle,可以用 npx tauri-windows-bundle 直接运行。

@choochmeque/tauri-windows-bundle 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@choochmeque/tauri-windows-bundle 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@choochmeque/tauri-windows-bundle 可以商用吗?

@choochmeque/tauri-windows-bundle 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@choochmeque/tauri-windows-bundle 的下载量有多少?

根据 npm 官方下载统计,@choochmeque/tauri-windows-bundle 在 2026/10/10 – 2026/11/08 这 30 天内被下载 9,941 次,日均约 331 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@choochmeque/tauri-windows-bundle 还在维护吗?

最新版本 0.2.0 发布于 2026/09/16(1 个月前);至今共发布 30 个版本,其中过去 12 个月发布了 30 个;首次发布于 2026/01/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。