Skip to content
Tauri 中文网

环境变量

这是 tauri 核心包和 tauri CLI 使用的所有环境变量的文档。

¥This is a documentation of all environment variables used by tauri core crates and tauri CLI.

Tauri CLI

这些环境变量是 CLI 的输入,可能具有等效的 CLI 标志。

¥These environment variables are inputs to the CLI which may have an equivalent CLI flag.

  • CI — 如果设置,CLI 将在 CI 模式下运行,不需要任何用户交互。

    ¥CI — If set, the CLI will run in CI mode and won’t require any user interaction.

  • TAURI_CLI_CONFIG_DEPTH — 遍历并查找 tauri 配置文件的级别数。

    ¥TAURI_CLI_CONFIG_DEPTH — Number of levels to traverse and find tauri configuration file.

  • TAURI_CLI_PORT — 用于 CLI 内置开发服务器的端口。

    ¥TAURI_CLI_PORT — Port to use for the CLI built-in dev server.

  • TAURI_CLI_WATCHER_IGNORE_FILENAME.gitignore 样式文件的名称,用于控制 CLI 在 dev 命令中应监视哪些文件。CLI 将在每个目录中查找此文件名。

    ¥TAURI_CLI_WATCHER_IGNORE_FILENAME — Name of a .gitignore-style file to control which files should be watched by the CLI in dev command. The CLI will look for this file name in each directory.

  • TAURI_CLI_NO_DEV_SERVER_WAIT — 在构建 tauri 应用之前,跳过等待前端开发服务器启动的过程。

    ¥TAURI_CLI_NO_DEV_SERVER_WAIT — Skip waiting for the frontend dev server to start before building the tauri application.

  • TAURI_LINUX_AYATANA_APPINDICATOR — 将此变量设置为 true1 以强制在 Linux 上使用 libayatana-appindicator 作为系统托盘。

    ¥TAURI_LINUX_AYATANA_APPINDICATOR — Set this var to true or 1 to force usage of libayatana-appindicator for system tray on Linux.

  • TAURI_BUNDLER_WIX_FIPS_COMPLIANT — 指定打包器的 WiX FipsCompliant 选项。

    ¥TAURI_BUNDLER_WIX_FIPS_COMPLIANT — Specify the bundler’s WiX FipsCompliant option.

  • TAURI_BUNDLER_TOOLS_GITHUB_MIRROR - 指定 GitHub 镜像以下载 tauri bundler 使用的文件和工具。

    ¥TAURI_BUNDLER_TOOLS_GITHUB_MIRROR - Specify a GitHub mirror to download files and tools used by tauri bundler.

  • TAURI_BUNDLER_TOOLS_GITHUB_MIRROR_TEMPLATE - 指定 GitHub 镜像模板以下载 tauri bundler 使用的文件和工具,例如:https://mirror.example.com/<owner>/<repo>/releases/download/<version>/<asset>

    ¥TAURI_BUNDLER_TOOLS_GITHUB_MIRROR_TEMPLATE - Specify a GitHub mirror template to download files and tools used by tauri bundler, for example: https://mirror.example.com/<owner>/<repo>/releases/download/<version>/<asset>.

  • TAURI_SKIP_SIDECAR_SIGNATURE_CHECK - 跳过签名 sidecar。

    ¥TAURI_SKIP_SIDECAR_SIGNATURE_CHECK - Skip signing sidecars.

  • TAURI_SIGNING_PRIVATE_KEY — 用于签署应用包的私钥,可以是字符串或文件路径。

    ¥TAURI_SIGNING_PRIVATE_KEY — Private key used to sign your app bundles, can be either a string or a path to the file.

  • TAURI_SIGNING_PRIVATE_KEY_PASSWORD — 签名私钥密码,请参阅 TAURI_SIGNING_PRIVATE_KEY

    ¥TAURI_SIGNING_PRIVATE_KEY_PASSWORD — The signing private key password, see TAURI_SIGNING_PRIVATE_KEY.

  • TAURI_SIGNING_RPM_KEY — 用于对 RPM 包进行签名的私有 GPG 密钥,导出为其 ASCII 装甲格式。

    ¥TAURI_SIGNING_RPM_KEY — The private GPG key used to sign the RPM bundle, exported to its ASCII-armored format.

  • TAURI_SIGNING_RPM_KEY_PASSPHRASE — 如果需要,则为 TAURI_SIGNING_RPM_KEY 的 GPG 密钥密码。

    ¥TAURI_SIGNING_RPM_KEY_PASSPHRASE — The GPG key passphrase for TAURI_SIGNING_RPM_KEY, if needed.

  • TAURI_WINDOWS_SIGNTOOL_PATH — 指定用于在 Windows 上对应用进行代码签名的 signtool.exe 路径。

    ¥TAURI_WINDOWS_SIGNTOOL_PATH — Specify a path to signtool.exe used for code signing the application on Windows.

  • APPLE_CERTIFICATE — 用于代码签名的 .p12 证书的 Base64 编码。要获取此值,请运行 openssl base64 -in MyCertificate.p12 -out MyCertificate-base64.txt

    ¥APPLE_CERTIFICATE — Base64 encoded of the .p12 certificate for code signing. To get this value, run openssl base64 -in MyCertificate.p12 -out MyCertificate-base64.txt.

  • APPLE_CERTIFICATE_PASSWORD — 用于导出证书的密码。

    ¥APPLE_CERTIFICATE_PASSWORD — The password you used to export the certificate.

  • APPLE_ID — 用于公证应用的 Apple ID。如果提供了此环境变量,还必须设置 APPLE_PASSWORDAPPLE_TEAM_ID。或者,可以使用 APPLE_API_KEYAPPLE_API_ISSUER 进行身份验证。

    ¥APPLE_ID — The Apple ID used to notarize the application. If this environment variable is provided, APPLE_PASSWORD and APPLE_TEAM_ID must also be set. Alternatively, APPLE_API_KEY and APPLE_API_ISSUER can be used to authenticate.

  • APPLE_PASSWORD — 用于对应用公证进行身份验证的 Apple 密码。如果指定了 APPLE_ID,则必需。可以使用特定于应用的密码。或者,除了以纯文本形式输入密码外,还可以使用 ‘@keychain:’ 或 ‘@env:’ 前缀后跟密钥串密码项名称或环境变量名称来指定密码。

    ¥APPLE_PASSWORD — The Apple password used to authenticate for application notarization. Required if APPLE_ID is specified. An app-specific password can be used. Alternatively to entering the password in plaintext, it may also be specified using a ‘@keychain:’ or ‘@env:’ prefix followed by a keychain password item name or environment variable name.

  • APPLE_TEAM_ID:开发者团队 ID。要查找你的团队 ID,请转到 Apple 开发者网站上的 账户 页面,并检查你的会员详细信息。

    ¥APPLE_TEAM_ID: Developer team ID. To find your Team ID, go to the Account page on the Apple Developer website, and check your membership details.

  • APPLE_API_KEY — 使用 JWT 进行公证身份验证的 APPLE_IDAPPLE_PASSWORD 的替代方案。还有一个选项允许自动管理 iOS 证书和配置文件。

    ¥APPLE_API_KEY — Alternative to APPLE_ID and APPLE_PASSWORD for notarization authentication using JWT. Also an option to allow automated iOS certificate and provisioning profile management.

  • API_PRIVATE_KEYS_DIR — 指定你的 AuthKey 文件所在的目录。参见 APPLE_API_KEY

    ¥API_PRIVATE_KEYS_DIR — Specify the directory where your AuthKey file is located. See APPLE_API_KEY.

  • APPLE_API_ISSUER — 发行人 ID。如果指定了 APPLE_API_KEY,则必需。

    ¥APPLE_API_ISSUER — Issuer ID. Required if APPLE_API_KEY is specified.

  • APPLE_API_KEY_PATH - API 密钥 .p8 文件的路径。如果未指定,对于 macOS 应用,打包程序会按顺序搜索以下目录以查找名为 ‘AuthKey_<api_key>.p8’ 的私钥文件:’./private_keys’、‘/private_keys’, ‘/.private_keys’ 和 ’~/.appstoreconnect/private_keys’。对于 iOS,此变量是必需的。

    ¥APPLE_API_KEY_PATH - path to the API key .p8 file. If not specified, for macOS apps the bundler searches the following directories in sequence for a private key file with the name of ‘AuthKey_<api_key>.p8’: ’./private_keys’, ‘/private_keys’, ‘/.private_keys’, and ’~/.appstoreconnect/private_keys’. For iOS this variable is required.

  • APPLE_SIGNING_IDENTITY — 用于代码签名的身份。覆盖 tauri.conf.json > bundle > macOS > signingIdentity。如果两者都未设置,则在提供时从 APPLE_CERTIFICATE 推断。

    ¥APPLE_SIGNING_IDENTITY — The identity used to code sign. Overwrites tauri.conf.json > bundle > macOS > signingIdentity. If neither are set, it is inferred from APPLE_CERTIFICATE when provided.

  • APPLE_PROVIDER_SHORT_NAME — 如果你的 Apple ID 连接到多个团队,你必须指定要用于公证应用的团队的提供商简称。覆盖 tauri.conf.json > bundle > macOS > providerShortName

    ¥APPLE_PROVIDER_SHORT_NAME — If your Apple ID is connected to multiple teams, you have to specify the provider short name of the team you want to use to notarize your app. Overwrites tauri.conf.json > bundle > macOS > providerShortName.

  • APPLE_DEVELOPMENT_TEAM — 用于在 iOS 上进行代码签名的团队 ID。覆盖 tauri.conf.json > bundle > iOS > developmentTeam。可以在 https://developer.apple.com/account#MembershipDetailsCard 中找到。

    ¥APPLE_DEVELOPMENT_TEAM — The team ID used to code sign on iOS. Overwrites tauri.conf.json > bundle > iOS > developmentTeam. Can be found in https://developer.apple.com/account#MembershipDetailsCard.

  • TAURI_WEBVIEW_AUTOMATION — 启用 webview 自动化(仅限 Linux)。

    ¥TAURI_WEBVIEW_AUTOMATION — Enables webview automation (Linux Only).

  • TAURI_ANDROID_PROJECT_PATH — tauri android 项目的路径,通常为 <project>/src-tauri/gen/android

    ¥TAURI_ANDROID_PROJECT_PATH — Path of the tauri android project, usually will be <project>/src-tauri/gen/android.

  • TAURI_IOS_PROJECT_PATH — tauri iOS 项目的路径,通常为 <project>/src-tauri/gen/ios

    ¥TAURI_IOS_PROJECT_PATH — Path of the tauri iOS project, usually will be <project>/src-tauri/gen/ios.

Tauri CLI Hook 命令

¥Tauri CLI Hook Commands

这些环境变量是为每个钩子命令(beforeDevCommandbeforeBuildCommand 等)设置的,这可能有助于有条件地构建你的前端或执行特定操作。

¥These environment variables are set for each hook command (beforeDevCommand, beforeBuildCommand, …etc) which could be useful to conditionally build your frontend or execute a specific action.

  • TAURI_ENV_DEBUGtrue 用于 dev 命令,否则为 build --debugfalse

    ¥TAURI_ENV_DEBUGtrue for dev command or build --debug, false otherwise.

  • TAURI_ENV_TARGET_TRIPLE — CLI 正在构建的目标三重版本。

    ¥TAURI_ENV_TARGET_TRIPLE — Target triple the CLI is building.

  • TAURI_ENV_ARCH — 目标 arch、x86_64aarch64…等。

    ¥TAURI_ENV_ARCH — Target arch, x86_64, aarch64…etc.

  • TAURI_ENV_PLATFORM — 目标平台、windowsdarwinlinux…等。

    ¥TAURI_ENV_PLATFORM — Target platform, windows, darwin, linux…etc.

  • TAURI_ENV_PLATFORM_VERSION — 构建平台版本

    ¥TAURI_ENV_PLATFORM_VERSION — Build platform version

  • TAURI_ENV_FAMILY — 目标平台系列 unixwindows

    ¥TAURI_ENV_FAMILY — Target platform family unix or windows.


Tauri 中文网 - 粤ICP备13048890号