|
@@ -8,7 +8,7 @@ use crate::bundle::{
|
|
|
path_utils::{copy_file, FileOpts},
|
|
|
settings::Settings,
|
|
|
};
|
|
|
-use anyhow::Context;
|
|
|
+use anyhow::{bail, Context};
|
|
|
use handlebars::{to_json, Handlebars};
|
|
|
use log::info;
|
|
|
use regex::Regex;
|
|
@@ -348,6 +348,24 @@ fn run_light(
|
|
|
// Ok(())
|
|
|
// }
|
|
|
|
|
|
+fn validate_version(version: &str) -> anyhow::Result<()> {
|
|
|
+ let version = semver::Version::parse(version).context("invalid app version")?;
|
|
|
+ if version.major > 255 {
|
|
|
+ bail!("app version major number cannot be greater than 255");
|
|
|
+ }
|
|
|
+ if version.minor > 255 {
|
|
|
+ bail!("app version minor number cannot be greater than 255");
|
|
|
+ }
|
|
|
+ if version.patch > 65535 {
|
|
|
+ bail!("app version patch number cannot be greater than 65535");
|
|
|
+ }
|
|
|
+ if !(version.pre.is_empty() && version.build.is_empty()) {
|
|
|
+ bail!("app version cannot have build metadata or pre-release identifier");
|
|
|
+ }
|
|
|
+
|
|
|
+ Ok(())
|
|
|
+}
|
|
|
+
|
|
|
// Entry point for bundling and creating the MSI installer. For now the only supported platform is Windows x64.
|
|
|
pub fn build_wix_app_installer(
|
|
|
settings: &Settings,
|
|
@@ -364,6 +382,8 @@ pub fn build_wix_app_installer(
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ validate_version(settings.version_string())?;
|
|
|
+
|
|
|
// target only supports x64.
|
|
|
info!("Target: {}", arch);
|
|
|
|