# @choochmeque/tauri-windows-bundle 中文文档

规范地址：https://npmcn.com/package/%40choochmeque/tauri-windows-bundle/

版本：0\.2\.0
npm 元数据更新时间：2026-09-16T15:59:10.927Z
中文译文更新时间：2026-11-09T14:30:55.185Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40choochmeque/tauri-windows-bundle
原文对照：https://npmcn.com/package/%40choochmeque/tauri-windows-bundle/?lang=original
项目主页：https://github.com/Choochmeque/tauri-windows-bundle#readme
源码仓库：https://github.com/Choochmeque/tauri-windows-bundle

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：223 kB，35 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：3 个
- 首次发布：2026-01-02T01:28:59.242Z
- 最新版本发布：2026-09-16T15:59:10.547Z
- 近 30 天下载量：9941（2026-10-10 至 2026-11-08，npm 官方下载统计）
- 已发布版本数：30（近 12 个月 30 个）

## 中文简介

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

## 安装

```sh
npm install @choochmeque/tauri-windows-bundle
```

也可以使用：`pnpm add @choochmeque/tauri-windows-bundle`、`yarn add @choochmeque/tauri-windows-bundle`、`bun add @choochmeque/tauri-windows-bundle`

## README

# 圆窗

[![npm](https://img.shields.io/npm/v/@choochmeque/tauri-windows-bundle.svg)](https://www.npmjs.com/package/@choochmeque/tauri-windows-bundle) [![codecov](https://codecov.io/gh/Choochmeque/tauri-windows-bundle/branch/main/graph/badge.svg)](https://codecov.io/gh/Choochmeque/tauri-windows-bundle) [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://npmcn.com/package/%40choochmeque/tauri-windows-bundle/LICENSE)

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

## 特征

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

## 先决条件

-   [锈](https://rustup.rs/) 有 Windows 目标
-   Windows SDK (用于签名)

```bash
# 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`](https://github.com/Choochmeque/msixbundle-rs) 二进制自动被运出 `optionalDependencies` 侧车([`@choochmeque/msixbundle-cli-win32`](https://www.npmjs.com/package/@choochmeque/msixbundle-cli-win32))——不需要单独安装.

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

## 安装

```bash
# 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`

## 使用量

### 初始化

```bash
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` 将由此获得资产来源。 例如,与

```json
// 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 缩放、任务栏/启动图标和主题意识牌:

```bash
npx @choochmeque/tauri-windows-bundle init --all-variants
```

| 旗帜 | 生成的文件 |
| --- | --- |
| `--scale` | `<asset>.scale-100/125/150/200/400.png` 用于 StoreLogo,平方44x44Logo,平方150x150Logo |
| `--target-size` | `Square44x44Logo.targetsize-16/20/24/30/32/36/40/48/60/64/72/80/96/256.png` (任务栏,启动列表,跳出列表) |
| `--unplated` | `Square44x44Logo.targetsize-N_altform-unplated.png` (透明背景) |
| `--light-unplated` | `Square44x44Logo.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`数字 :

```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` 数值.

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

```json
{
  "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)](https://datatracker.ietf.org/doc/html/rfc7396)中定义 Windows 特定设置 `identifier`, (中文(简体) ), `productName`,或 `bundle.publisher` 分别.

### 构建

```bash
# 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 参考

```bash
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
```

## 窗口扩展

### 文件关联

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

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

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

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

### 协议处理器

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

### 共享目标

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

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

### 启动任务

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

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

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

### 背景菜单

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

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

### 背景任务

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

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

### 列表扩展

```bash
npx @choochmeque/tauri-windows-bundle extension list
```

### 应用程序执行别名

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

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

### 应用服务

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

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

### 敬酒活动

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

```bash
# 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).

### 自动播放

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

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

### 打印任务设置

添加自定义打印设置 UI.

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

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

### 缩略图处理器

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

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

### 预览处理器

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

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

### 列表扩展

```bash
npx @choochmeque/tauri-windows-bundle extension list
```

### 删除扩展

```bash
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证书

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

通过环境变量设置密码 :

```bash
export MSIX_PFX_PASSWORD=your-password
```

### 选项2: Windows 证书存储

使用从 `tauri.conf.json`数字 :

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

## GitHub 动作

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

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

```yaml
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`。 。 。 .

## 许可证

[麻省理工学院](https://npmcn.com/package/%40choochmeque/tauri-windows-bundle/LICENSE)

## 常见问题

### @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 和提交记录判断。

