Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 46 additions & 33 deletions tugger-wix/src/simple_msi_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ pub struct WiXSimpleMsiBuilder {
product_icon: Option<PathBuf>,
help_url: Option<String>,
eula_rtf: Option<PathBuf>,
add_to_path: Option<bool>,
/// Banner BMP image.
///
/// Dimensions are 493 x 58.
Expand Down Expand Up @@ -168,6 +169,13 @@ impl WiXSimpleMsiBuilder {
self
}

/// Display option to add install folder to the PATH Environment.
#[must_use]
pub fn add_to_path(mut self, value: bool) -> Self {
self.add_to_path = Some(value);
self
}

/// Set the path to a bmp file containing a banner to use for install.
///
/// The dimensions of the banner should be 493 x 58.
Expand Down Expand Up @@ -367,25 +375,27 @@ impl WiXSimpleMsiBuilder {
.attr("Name", &self.product_name),
)?;

writer.write(
XmlEvent::start_element("Component")
.attr("Id", "Path")
.attr("Guid", &self.path_component_guid())
.attr("Win64", "$(var.Win64)")
.attr("KeyPath", "yes"),
)?;
writer.write(
XmlEvent::start_element("Environment")
.attr("Id", "PATH")
.attr("Name", "PATH")
.attr("Value", "[APPLICATIONFOLDER]")
.attr("Permanent", "no")
.attr("Part", "last")
.attr("Action", "set")
.attr("System", "yes"),
)?;
writer.write(XmlEvent::end_element().name("Environment"))?;
writer.write(XmlEvent::end_element().name("Component"))?;
if self.add_to_path.unwrap_or(true) {
writer.write(
XmlEvent::start_element("Component")
.attr("Id", "Path")
.attr("Guid", &self.path_component_guid())
.attr("Win64", "$(var.Win64)")
.attr("KeyPath", "yes"),
)?;
writer.write(
XmlEvent::start_element("Environment")
.attr("Id", "PATH")
.attr("Name", "PATH")
.attr("Value", "[APPLICATIONFOLDER]")
.attr("Permanent", "no")
.attr("Part", "last")
.attr("Action", "set")
.attr("System", "yes"),
)?;
writer.write(XmlEvent::end_element().name("Environment"))?;
writer.write(XmlEvent::end_element().name("Component"))?;
}

if let Some(license_source) = &self.license_source {
writer.write(
Expand Down Expand Up @@ -435,22 +445,25 @@ impl WiXSimpleMsiBuilder {
writer.write(XmlEvent::start_element("ComponentRef").attr("Id", "License"))?;
writer.write(XmlEvent::end_element().name("ComponentRef"))?;
}
if self.add_to_path.unwrap_or(true) {

writer.write(
XmlEvent::start_element("Feature")
.attr("Id", "Environment")
.attr("Title", "PATH Environment Variable")
.attr(
"Description",
"Add the install location to the PATH system environment variable",
)
.attr("Level", "1")
.attr("Absent", "allow"),
)?;

writer.write(
XmlEvent::start_element("Feature")
.attr("Id", "Environment")
.attr("Title", "PATH Environment Variable")
.attr(
"Description",
"Add the install location to the PATH system environment variable",
)
.attr("Level", "1")
.attr("Absent", "allow"),
)?;
writer.write(XmlEvent::start_element("ComponentRef").attr("Id", "Path"))?;
writer.write(XmlEvent::end_element().name("ComponentRef"))?;
writer.write(XmlEvent::end_element().name("Feature"))?;
writer.write(XmlEvent::start_element("ComponentRef").attr("Id", "Path"))?;
writer.write(XmlEvent::end_element().name("ComponentRef"))?;
writer.write(XmlEvent::end_element().name("Feature"))?;

}
writer.write(XmlEvent::end_element().name("Feature"))?;

writer.write(
Expand Down
7 changes: 7 additions & 0 deletions tugger/docs/tugger_starlark_type_wix_msi_builder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,13 @@

Path to a file providing the icon for the installed application.

.. py:attribute:: add_to_path

(``bool``)

When set (on be default), provide an option in the msi installer wizard to
add the application install folder to the system PATH environment.

.. py:attribute:: upgrade_code

(``str``)
Expand Down
3 changes: 3 additions & 0 deletions tugger/src/starlark/wix_msi_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ impl TypedValue for WiXMsiBuilderValue {
"product_icon_path" => {
inner.builder = inner.builder.clone().product_icon_path(value.to_string());
}
"add_to_path" => {
inner.builder = inner.builder.clone().add_to_path(value.to_bool());
}
"upgrade_code" => {
inner.builder = inner.builder.clone().upgrade_code(value.to_string());
}
Expand Down