Skip to content

Commit

Permalink
fix(bundler): change build metadata verification into a warning (#12136)
Browse files Browse the repository at this point in the history
Co-authored-by: akorovacki <[email protected]>
Co-authored-by: Fabian-Lars <[email protected]>
  • Loading branch information
3 people authored Jan 23, 2025
1 parent 5432752 commit f5a59b9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changes/change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'tauri-bundler': 'patch:bug'
---

The NSIS bundler will now replace non-numeric build metadata with `0` instead of returning an error.
10 changes: 7 additions & 3 deletions crates/tauri-bundler/src/bundle/windows/nsis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fn get_and_extract_nsis(nsis_toolset_path: &Path, _tauri_tools_path: &Path) -> c
Ok(())
}

fn add_build_number_if_needed(version_str: &str) -> anyhow::Result<String> {
fn try_add_numeric_build_number(version_str: &str) -> anyhow::Result<String> {
let version = semver::Version::parse(version_str).context("invalid app version")?;
if !version.build.is_empty() {
let build = version.build.parse::<u64>();
Expand All @@ -141,7 +141,10 @@ fn add_build_number_if_needed(version_str: &str) -> anyhow::Result<String> {
version.major, version.minor, version.patch, version.build
));
} else {
anyhow::bail!("optional build metadata in app version must be numeric-only");
log::warn!(
"Unable to parse version build metadata. Numeric value expected, received: `{}`. This will be replaced with `0` in `VIProductVersion` because Windows requires this field to be numeric.",
version.build
);
}
}

Expand All @@ -150,6 +153,7 @@ fn add_build_number_if_needed(version_str: &str) -> anyhow::Result<String> {
version.major, version.minor, version.patch,
))
}

fn build_nsis_app_installer(
settings: &Settings,
_nsis_toolset_path: &Path,
Expand Down Expand Up @@ -214,7 +218,7 @@ fn build_nsis_app_installer(
data.insert("version", to_json(version));
data.insert(
"version_with_build",
to_json(add_build_number_if_needed(version)?),
to_json(try_add_numeric_build_number(version)?),
);

data.insert(
Expand Down

0 comments on commit f5a59b9

Please sign in to comment.