Skip to content

Commit ac1dfd8

Browse files
authored
feat(bundler): initialize msi install path with previous location (#3158)
1 parent 1e7c2cb commit ac1dfd8

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"tauri-bundler": patch
3+
---
4+
5+
Initialize the preselected installation path with the location of the previous installation.

tooling/bundler/src/bundle/windows/msi/wix.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,10 @@ pub fn build_wix_app_installer(
465465

466466
data.insert("product_name", to_json(settings.product_name()));
467467
data.insert("version", to_json(settings.version_string()));
468-
let manufacturer = settings.bundle_identifier().to_string();
469-
data.insert("manufacturer", to_json(manufacturer.as_str()));
468+
let bundle_id = settings.bundle_identifier();
469+
let manufacturer = bundle_id.split('.').nth(1).unwrap_or(bundle_id);
470+
data.insert("bundle_id", to_json(bundle_id));
471+
data.insert("manufacturer", to_json(manufacturer));
470472
let upgrade_code = Uuid::new_v5(
471473
&Uuid::NAMESPACE_DNS,
472474
format!("{}.app.x64", &settings.main_binary_name()).as_bytes(),

tooling/bundler/src/bundle/windows/templates/main.wxs

+17-5
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646
<Property Id="ARPNOREPAIR" Value="yes" Secure="yes" /> <!-- Remove repair -->
4747
<SetProperty Id="ARPNOMODIFY" Value="1" After="InstallValidate" Sequence="execute"/>
4848

49+
<!-- initialize with previous InstallDir -->
50+
<Property Id="INSTALLDIR">
51+
<RegistrySearch Id="PrevInstallDirReg" Root="HKCU" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}" Name="InstallDir" Type="raw"/>
52+
</Property>
53+
4954
<!-- launch app checkbox -->
5055
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch {{{product_name}}}" />
5156
<Property Id="WixShellExecTarget" Value="{{{app_exe_source}}}" />
@@ -79,7 +84,7 @@
7984
<Component Id="ApplicationShortcutDesktop" Guid="*">
8085
<Shortcut Id="ApplicationDesktopShortcut" Name="{{{product_name}}}" Description="Runs {{{product_name}}}" Target="[!Path]" WorkingDirectory="INSTALLDIR" />
8186
<RemoveFolder Id="DesktopFolder" On="uninstall" />
82-
<RegistryValue Root="HKCU" Key="Software\\{{{product_name}}}" Name="installed" Type="integer" Value="1" KeyPath="yes" />
87+
<RegistryValue Root="HKCU" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}" Name="Desktop Shortcut" Type="integer" Value="1" KeyPath="yes" />
8388
</Component>
8489
</Directory>
8590
<Directory Id="$(var.PlatformProgramFilesFolder)" Name="PFiles">
@@ -91,6 +96,11 @@
9196
</Directory>
9297

9398
<DirectoryRef Id="INSTALLDIR">
99+
<Component Id="RegistryEntries" Guid="*">
100+
<RegistryKey Root="HKCU" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}">
101+
<RegistryValue Name="InstallDir" Type="string" Value="[INSTALLDIR]" KeyPath="yes" />
102+
</RegistryKey>
103+
</Component>
94104
<Component Id="Path" Guid="{{{path_component_guid}}}" Win64="$(var.Win64)">
95105
<File Id="Path" Source="{{{app_exe_source}}}" KeyPath="yes" Checksum="yes"/>
96106
</Component>
@@ -122,9 +132,9 @@
122132
<RemoveFolder Id="INSTALLDIR"
123133
On="uninstall" />
124134

125-
<RegistryValue Root="HKCR"
135+
<RegistryValue Root="HKCU"
126136
Key="Software\\{{{manufacturer}}}\\{{{product_name}}}"
127-
Name="installed"
137+
Name="Uninstaller Shortcut"
128138
Type="integer"
129139
Value="1"
130140
KeyPath="yes" />
@@ -139,10 +149,10 @@
139149
Target="[!Path]"
140150
Icon="ProductIcon"
141151
WorkingDirectory="INSTALLDIR">
142-
<ShortcutProperty Key="System.AppUserModel.ID" Value="{{{manufacturer}}}"/>
152+
<ShortcutProperty Key="System.AppUserModel.ID" Value="{{{bundle_id}}}"/>
143153
</Shortcut>
144154
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
145-
<RegistryValue Root="HKCU" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
155+
<RegistryValue Root="HKCU" Key="Software\\{{{manufacturer}}}\\{{{product_name}}}" Name="Start Menu Shortcut" Type="integer" Value="1" KeyPath="yes"/>
146156
</Component>
147157
</DirectoryRef>
148158

@@ -166,6 +176,8 @@
166176
Display="expand"
167177
Absent="disallow">
168178

179+
<ComponentRef Id="RegistryEntries"/>
180+
169181
{{#each resource_file_ids as |resource_file_id| ~}}
170182
<ComponentRef Id="{{ resource_file_id }}"/>
171183
{{/each~}}

0 commit comments

Comments
 (0)