From c2d4338091536bf20fbf906dd9d356225e5d9a6f Mon Sep 17 00:00:00 2001 From: Andrew Leech Date: Wed, 19 Jul 2023 15:23:28 +1000 Subject: [PATCH] tugger-wix: Add option to set msi as per-user install rather than per-machine. --- tugger-wix/src/simple_msi_builder.rs | 15 ++++++++++++++- .../docs/tugger_starlark_type_wix_msi_builder.rst | 7 +++++++ tugger/src/starlark/wix_msi_builder.rs | 3 +++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/tugger-wix/src/simple_msi_builder.rs b/tugger-wix/src/simple_msi_builder.rs index 124246515..2fe9fbeb6 100644 --- a/tugger-wix/src/simple_msi_builder.rs +++ b/tugger-wix/src/simple_msi_builder.rs @@ -48,6 +48,7 @@ pub struct WiXSimpleMsiBuilder { upgrade_code: Option, package_keywords: Option, package_description: Option, + per_user_install: Option, license_source: Option, product_icon: Option, help_url: Option, @@ -140,6 +141,13 @@ impl WiXSimpleMsiBuilder { self } + /// If enabled install per-user rather than per-machine. + #[must_use] + pub fn per_user_install(mut self, value: bool) -> Self { + self.per_user_install = Some(value); + self + } + /// Set the path to the file containing the license for this application. #[must_use] pub fn license_path>(mut self, path: P) -> Self { @@ -307,10 +315,15 @@ impl WiXSimpleMsiBuilder { .attr("InstallerVersion", &self.package_installer_version) .attr("Languages", &self.package_languages) .attr("Compressed", "yes") - .attr("InstallScope", "perMachine") .attr("SummaryCodepage", "1252") .attr("Platform", "$(sys.BUILDARCH)"); + let package = if self.per_user_install.unwrap_or(false) { + package + } else { + package.attr("InstallScope", "perMachine") + }; + let package = if let Some(keywords) = &self.package_keywords { package.attr("Keywords", keywords) } else { diff --git a/tugger/docs/tugger_starlark_type_wix_msi_builder.rst b/tugger/docs/tugger_starlark_type_wix_msi_builder.rst index 4ecc7cee2..fe20ac9ce 100644 --- a/tugger/docs/tugger_starlark_type_wix_msi_builder.rst +++ b/tugger/docs/tugger_starlark_type_wix_msi_builder.rst @@ -106,6 +106,13 @@ Keywords for the application being installed. + .. py:attribute:: per_user_install + + (``bool``) + + When set (off be default) the application will be installed per-user + rather than per-machine. + .. py:attribute:: product_icon_path (``str``) diff --git a/tugger/src/starlark/wix_msi_builder.rs b/tugger/src/starlark/wix_msi_builder.rs index c5f90f7b1..aba5d9238 100644 --- a/tugger/src/starlark/wix_msi_builder.rs +++ b/tugger/src/starlark/wix_msi_builder.rs @@ -103,6 +103,9 @@ impl TypedValue for WiXMsiBuilderValue { "package_keywords" => { inner.builder = inner.builder.clone().package_keywords(value.to_string()); } + "per_user_install" => { + inner.builder = inner.builder.clone().per_user_install(value.to_bool()); + } "product_icon_path" => { inner.builder = inner.builder.clone().product_icon_path(value.to_string()); }