Skip to content

Commit

Permalink
feat(bundler/msi): add perMachine option, disabled by default, closes
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Jun 28, 2022
1 parent fd125f7 commit 46ff39d
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 16 deletions.
9 changes: 9 additions & 0 deletions .changes/wix-per-machine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"tauri-bundler": "patch"
"cli.rs": "patch"
"cli.js": "patch"
---

Added `perMachine` option to `tauri.conf.json > tauri > bundle > windows > wix`, disabled by default.
**Breaking change** `msi` installer will install your app per-user by default now.

5 changes: 4 additions & 1 deletion core/tauri-utils/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,12 @@ pub struct WixConfig {
pub banner_path: Option<PathBuf>,
/// Path to a bitmap file to use on the installation user interface dialogs.
/// It is used on the welcome and completion dialogs.

///
/// The required dimensions are 493px × 312px.
pub dialog_image_path: Option<PathBuf>,
/// Install for all users on the machine.
#[serde(default)]
pub per_machine: bool,
}

/// Install modes for the Webview2 runtime.
Expand Down
4 changes: 3 additions & 1 deletion tooling/bundler/src/bundle/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,11 @@ pub struct WixSettings {
pub banner_path: Option<PathBuf>,
/// Path to a bitmap file to use on the installation user interface dialogs.
/// It is used on the welcome and completion dialogs.

///
/// The required dimensions are 493px × 312px.
pub dialog_image_path: Option<PathBuf>,
/// Install for all users on the machine.
pub per_machine: bool,
}

/// The Windows bundle settings.
Expand Down
8 changes: 8 additions & 0 deletions tooling/bundler/src/bundle/windows/msi/wix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,14 @@ pub fn build_wix_app_installer(
data.insert("feature_group_refs", to_json(&wix.feature_group_refs));
data.insert("feature_refs", to_json(&wix.feature_refs));
data.insert("merge_refs", to_json(&wix.merge_refs));
if wix.per_machine {
data.insert("per_machine", to_json(true));
data.insert("install_scope", to_json("perMachine"));
data.insert("registry_root", to_json("HKLM"));
} else {
data.insert("install_scope", to_json("perUser"));
data.insert("registry_root", to_json("HKCU"));
}
fragment_paths = wix.fragment_paths.clone();
enable_elevated_update_task = wix.enable_elevated_update_task;

Expand Down
67 changes: 54 additions & 13 deletions tooling/bundler/src/bundle/windows/templates/main.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
InstallerVersion="450"
Languages="0"
Compressed="yes"
InstallScope="perMachine"
InstallScope="{{{install_scope}}}"
SummaryCodepage="!(loc.TauriCodepage)"/>

<!-- https://docs.microsoft.com/en-us/windows/win32/msi/reinstallmode -->
Expand Down Expand Up @@ -58,7 +58,7 @@

<!-- initialize with previous InstallDir -->
<Property Id="INSTALLDIR">
<RegistrySearch Id="PrevInstallDirReg" Root="HKCU" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}" Name="InstallDir" Type="raw"/>
<RegistrySearch Id="PrevInstallDirReg" Root="{{{registry_root}}}" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}" Name="InstallDir" Type="raw"/>
</Property>

<!-- launch app checkbox -->
Expand Down Expand Up @@ -94,40 +94,81 @@
<Component Id="ApplicationShortcutDesktop" Guid="*">
<Shortcut Id="ApplicationDesktopShortcut" Name="{{{product_name}}}" Description="Runs {{{product_name}}}" Target="[!Path]" WorkingDirectory="INSTALLDIR" />
<RemoveFolder Id="DesktopFolder" On="uninstall" />
<RegistryValue Root="HKCU" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}" Name="Desktop Shortcut" Type="integer" Value="1" KeyPath="yes" />
<RegistryValue Root="{{{registry_root}}}" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}" Name="Desktop Shortcut" Type="integer" Value="1" {{#if per_machine}}KeyPath="yes"{{/if}} />
</Component>
</Directory>
{{#if per_machine}}
<Directory Id="$(var.PlatformProgramFilesFolder)" Name="PFiles">
<Directory Id="INSTALLDIR" Name="{{{product_name}}}"/>
</Directory>
{{else}}
<Directory Id="LocalAppDataFolder" Name="LData">
<Directory Id="INSTALLDIR" Name="{{{product_name}}}"/>
</Directory>
{{/if}}
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="{{{product_name}}}"/>
</Directory>
</Directory>

<DirectoryRef Id="INSTALLDIR">
<Component Id="RegistryEntries" Guid="*">
<RegistryKey Root="HKCU" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}">
<RegistryValue Name="InstallDir" Type="string" Value="[INSTALLDIR]" KeyPath="yes" />
<RegistryKey Root="{{{registry_root}}}" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}">
<RegistryValue Name="InstallDir" Type="string" Value="[INSTALLDIR]" {{#if per_machine}}KeyPath="yes"{{/if}} />
</RegistryKey>
</Component>
<Component Id="Path" Guid="{{{path_component_guid}}}" Win64="$(var.Win64)">
<File Id="Path" Source="{{{app_exe_source}}}" KeyPath="yes" Checksum="yes"/>
{{#unless per_machine}}
<RegistryValue Root="HKCU" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}"
Name="InstallDir"
Value="[INSTALLDIR]"
Type="string"
KeyPath="yes" />
{{/unless}}
<File Id="Path" Source="{{{app_exe_source}}}" {{#if per_machine}}KeyPath="yes"{{/if}} Checksum="yes"/>
</Component>
{{#each binaries as |bin| ~}}
<Component Id="{{ bin.id }}" Guid="{{bin.guid}}" Win64="$(var.Win64)">
<File Id="Path_{{ bin.id }}" Source="{{bin.path}}" KeyPath="yes"/>
{{#unless per_machine}}
<RegistryValue Root="HKCU" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}"
Name="InstallDir"
Value="[INSTALLDIR]"
Type="string"
KeyPath="yes" />
{{/unless}}
<File Id="Path_{{ bin.id }}" Source="{{bin.path}}" {{#if per_machine}}KeyPath="yes"{{/if}}/>
</Component>
{{/each~}}
{{#if enable_elevated_update_task}}
<Component Id="UpdateTask" Guid="C492327D-9720-4CD5-8DB8-F09082AF44BE" Win64="$(var.Win64)">
<File Id="UpdateTask" Source="update.xml" KeyPath="yes" Checksum="yes"/>
{{#unless per_machine}}
<RegistryValue Root="HKCU" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}"
Name="InstallDir"
Value="[INSTALLDIR]"
Type="string"
KeyPath="yes" />
{{/unless}}
<File Id="UpdateTask" Source="update.xml" {{#if per_machine}}KeyPath="yes"{{/if}} Checksum="yes"/>
</Component>
<Component Id="UpdateTaskInstaller" Guid="011F25ED-9BE3-50A7-9E9B-3519ED2B9932" Win64="$(var.Win64)">
<File Id="UpdateTaskInstaller" Source="install-task.ps1" KeyPath="yes" Checksum="yes"/>
{{#unless per_machine}}
<RegistryValue Root="HKCU" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}"
Name="InstallDir"
Value="[INSTALLDIR]"
Type="string"
KeyPath="yes" />
{{/unless}}
<File Id="UpdateTaskInstaller" Source="install-task.ps1" {{#if per_machine}}KeyPath="yes"{{/if}} Checksum="yes"/>
</Component>
<Component Id="UpdateTaskUninstaller" Guid="D4F6CC3F-32DC-5FD0-95E8-782FFD7BBCE1" Win64="$(var.Win64)">
<File Id="UpdateTaskUninstaller" Source="uninstall-task.ps1" KeyPath="yes" Checksum="yes"/>
{{#unless per_machine}}
<RegistryValue Root="HKCU" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}"
Name="InstallDir"
Value="[INSTALLDIR]"
Type="string"
KeyPath="yes" />
{{/unless}}
<File Id="UpdateTaskUninstaller" Source="uninstall-task.ps1" {{#if per_machine}}KeyPath="yes"{{/if}} Checksum="yes"/>
</Component>
{{/if}}
{{{resources}}}
Expand All @@ -142,12 +183,12 @@
<RemoveFolder Id="INSTALLDIR"
On="uninstall" />

<RegistryValue Root="HKCU"
<RegistryValue Root="{{{registry_root}}}"
Key="Software\\{{{manufacturer}}}\\{{{product_name}}}"
Name="Uninstaller Shortcut"
Type="integer"
Value="1"
KeyPath="yes" />
KeyPath="yes"/>
</Component>
</DirectoryRef>

Expand All @@ -162,7 +203,7 @@
<ShortcutProperty Key="System.AppUserModel.ID" Value="{{{bundle_id}}}"/>
</Shortcut>
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}" Name="Start Menu Shortcut" Type="integer" Value="1" KeyPath="yes"/>
<RegistryValue Root="{{{registry_root}}}" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}" Name="Start Menu Shortcut" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>

Expand Down
7 changes: 6 additions & 1 deletion tooling/cli/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1437,11 +1437,16 @@
]
},
"dialogImagePath": {
"description": "Path to a bitmap file to use on the installation user interface dialogs. It is used on the welcome and completion dialogs. The required dimensions are 493px × 312px.",
"description": "Path to a bitmap file to use on the installation user interface dialogs. It is used on the welcome and completion dialogs.\n\nThe required dimensions are 493px × 312px.",
"type": [
"string",
"null"
]
},
"perMachine": {
"description": "Install for all users on the machine.",
"default": false,
"type": "boolean"
}
},
"additionalProperties": false
Expand Down
1 change: 1 addition & 0 deletions tooling/cli/src/helpers/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ pub fn wix_settings(config: WixConfig) -> tauri_bundler::WixSettings {
enable_elevated_update_task: config.enable_elevated_update_task,
banner_path: config.banner_path,
dialog_image_path: config.dialog_image_path,
per_machine: config.per_machine,
}
}

Expand Down

0 comments on commit 46ff39d

Please sign in to comment.