Repository: tauri-apps/tauri (language: rust)

Issue:
[bug] NSIS bundler: semver version metadata is required to be numeric, but shouldn't be
### Describe the bug

When bundling an app with the tauri version e.g. "2.5.0-beta+1a2b3c4d", I get an error that "optional build metadata in app version must be numeric-only".

My understanding is that this limitation only should apply to the Wix bundler (#5286), but I am using NSIS, which uses windows' ProductVersion instead of FileVersion.

Since ProductVersion can accept arbitrary strings, there appears to be no technical reason that this limitation should exist for NSIS bundlers.

### Reproduction

1. Create a tauri project with `project > version` set to e.g. `0.1.0-beta+123` and `tauri > bundle > targets` set to `"nsis"`.
2. `tauri build`
3. Observe the correct bundle name, and ProductVersion in the file's properties:
```
    Finished 1 bundle at:
        .\src-tauri\target\release\bundle\nsis\issue_0.1.0-beta+123_x64-setup.exe
```
![image](https://github.com/tauri-apps/tauri/assets/8306042/fda4810d-c3ad-4ed3-b296-5d103f50aef5)

4. Change `project > version` to `0.1.0-beta+abc`
5. `tauri build`
6. Observe the error:
```
       Error failed to bundle project: optional build metadata in app version must be numeric-only
```

### Expected behavior

Step 6 should function exactly the same as step 3.

### Platform and versions

```text
[✔] Environment
    - OS: Windows 10.0.22621 X64
    ✔ WebView2: 118.0.2088.46
    ✔ MSVC: Visual Studio Professional 2022
    ✔ rustc: 1.66.0 (69f9c33d7 2022-12-12)
    ✔ Cargo: 1.66.0 (d65d197ad 2022-11-15)
    ✔ rustup: 1.25.1 (bb60b1e89 2022-07-12)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 16.20.2
    - yarn: 1.22.19
    - npm: 8.19.4

[-] Packages
    - tauri [RUST]: 1.5.2
    - tauri-build [RUST]: 1.5.0
    - wry [RUST]: 0.24.4
    - tao [RUST]: 0.16.4
    - tauri-cli [RUST]: not installed!
    - @tauri-apps/api [NPM]: not installed!
    - @tauri-apps/cli [NPM]: 1.5.2 (outdated, latest: 1.5.4)

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: localhost
```

### Stack trace

_No response_

### Additional context

_No response_


Discussion / hints:
I think you can just:

```diff
--- a/tooling/bundler/src/bundle/windows/nsis.rs
+++ b/tooling/bundler/src/bundle/windows/nsis.rs
@@ -124,15 +124,10 @@ fn get_and_extract_nsis(nsis_toolset_path: &Path, _tauri_tools_path: &Path) -> c
 fn add_build_number_if_needed(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>();
-    if build.is_ok() {
       return Ok(format!(
         "{}.{}.{}.{}",
         version.major, version.minor, version.patch, version.build
       ));
-    } else {
-      anyhow::bail!("optional build metadata in app version must be numeric-only");
-    }
   }
 
   Ok(format!(
```

Fix patch:
diff --git a/.changes/change.md b/.changes/change.md
new file mode 100644
index 000000000000..80e314deee5f
--- /dev/null
+++ b/.changes/change.md
@@ -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.
diff --git a/crates/tauri-bundler/src/bundle/windows/nsis/mod.rs b/crates/tauri-bundler/src/bundle/windows/nsis/mod.rs
index 248152d532a1..f0b9fdc2ba70 100644
--- a/crates/tauri-bundler/src/bundle/windows/nsis/mod.rs
+++ b/crates/tauri-bundler/src/bundle/windows/nsis/mod.rs
@@ -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>();
@@ -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
+      );
     }
   }
 
@@ -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,
@@ -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(


Test patch: