tauri action支持中文名称打包的解决办法

241 阅读2分钟

{"accept-encoding": "gzip", "user-agent": "ureq/3.0.2", "accept": "*/*", "host": "objects.githubusercontent.com"} }

704 Info Response { status: 200, version: HTTP/1.1, headers: {"connection": "keep-alive", "content-length": "41297555", "content-type": "application/octet-stream", "server": "Windows-Azure-Blob/1.0 Microsoft-HTTPAPI/2.0", "date": "Sun, 02 Mar 2025 09:09:47 GMT", "<NOTICE>": "19 HEADERS ARE REDACTED"} }

705 Info validating hash

706 Info extracting WIX

707 Info Target: arm64

708 Running candle for "main.wxs"

709 Running light to produce D:\a\DeepChat\DeepChat\src-tauri\target\aarch64-pc-windows-msvc\release\bundle\msi\深度探索_0.0.2_arm64_en-US.msi

710failed to bundle project: error running light.exe: `failed to run C:\Users\runneradmin\AppData\Local\tauri\WixTools314\light.exe`

711 Error failed to bundle project: error running light.exe: `failed to run C:\Users\runneradmin\AppData\Local\tauri\WixTools314\light.exe`

712 ELIFECYCLE  Command failed with exit code 1.

713Error: Command "pnpm ["tauri","build","--target","aarch64-pc-windows-msvc"]" failed with exit code 1

在 Tauri 使用 GitHub Actions 打包 Windows MSI 时,如果遇到 error running light.exe 的错误,特别是在打包路径中包含非 ASCII 字符(如中文字符 抖音)时,问题可能与 WiX Toolset 不支持文件路径中的非 ASCII 字符有关

解决方案

1. 避免使用非 ASCII 字符

WiX Toolset 对于文件路径中包含非 ASCII 字符(例如中文字符)可能会出现问题。你可以尝试将生成的 MSI 文件名和路径中的中文字符替换为英文,或者使用拼音代替。

修改 tauri.conf.json 文件中的 productName 和打包相关的设置,确保它们不包含中文字符:

{
  "package": {
    "productName": "DouyinApp",  // 避免使用中文字符
    "version": "0.0.1"
  },
  "tauri": {
    "bundle": {
      "identifier": "com.example.douyinapp",
      "active": true,
      "targets": ["msi"],  
      "windows": {
        "certificateThumbprint": "",
        "timestampUrl": "http://timestamp.digicert.com",
        "iconPath": "src-tauri/icons/app.ico"
      }
    }
  }
}

productName: 将 抖音 修改为英文名称(如 DouyinApp)来避免中文字符。

确保生成的路径不包含中文字符,以确保 WiX Toolset 可以正常处理。

2.不要使用msi

不要msi就说明不会使用light.exe,所以就可以避免中文错误

"targets": ["nsis", "dmg", "deb", "app", "appimage", "rpm"],