diff --git a/.changes/set-static-vcruntime-envvar.md b/.changes/set-static-vcruntime-envvar.md new file mode 100644 index 000000000..59ee337c1 --- /dev/null +++ b/.changes/set-static-vcruntime-envvar.md @@ -0,0 +1,6 @@ +--- +"cli.rs": patch +"cli.js": patch +--- + +Configure the `STATIC_VCRUNTIME` environment variable so `tauri-build` statically links it on the build command. diff --git a/.changes/static-vcruntime-config-envvar.md b/.changes/static-vcruntime-config-envvar.md new file mode 100644 index 000000000..e0741ee4f --- /dev/null +++ b/.changes/static-vcruntime-config-envvar.md @@ -0,0 +1,5 @@ +--- +"tauri-build": patch +--- + +Only statically link the VC runtime when the `STATIC_VCRUNTIME` environment variable is set to `true` (automatically done by the Tauri CLI). diff --git a/core/tauri-build/src/lib.rs b/core/tauri-build/src/lib.rs index e8102e004..56578113f 100644 --- a/core/tauri-build/src/lib.rs +++ b/core/tauri-build/src/lib.rs @@ -187,7 +187,9 @@ pub fn try_build(attributes: Attributes) -> Result<()> { }; #[cfg(windows)] - static_vcruntime::build(); + if std::env::var("STATIC_VCRUNTIME").map_or(false, |v| v == "true") { + static_vcruntime::build(); + } cfg_alias("dev", !has_feature("custom-protocol")); diff --git a/core/tests/app-updater/build.rs b/core/tests/app-updater/build.rs index 03f0ee177..71557e5b9 100644 --- a/core/tests/app-updater/build.rs +++ b/core/tests/app-updater/build.rs @@ -2,4 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: MIT -fn main() {} +fn main() { + tauri_build::build() +} diff --git a/tooling/cli/src/interface/rust.rs b/tooling/cli/src/interface/rust.rs index d0e3fa7a8..92f73beff 100644 --- a/tooling/cli/src/interface/rust.rs +++ b/tooling/cli/src/interface/rust.rs @@ -104,6 +104,7 @@ pub fn build_project(runner: String, args: Vec) -> crate::Result<()> { Command::new(&runner) .args(&["build", "--features=custom-protocol"]) .args(args) + .env("STATIC_VCRUNTIME", "true") .pipe()? .output_ok() .with_context(|| format!("Result of `{} build` operation was unsuccessful", runner))?;