Skip to content

Commit 8ff282e

Browse files
committed
WiX installer: Allow v1.0 to coexist with v0.20
- Changed UpgradeCode to distinguish v1.x from v0.x products - Replaced MajorUpgrade with custom Upgrade element for v1.x only - Set fixed ProductCode for v1.x family (enables upgrades within v1.x) - Automatic version-based folder naming (DataLab_v{major} / DataLab {major}.{minor}) - Updated makewxs.py to generate install/display folder names from version This allows v0.20 and v1.0+ to be installed side-by-side while ensuring v1.x versions properly upgrade each other (v1.0.1 replaces v1.0.0, etc.)
1 parent 27db4d0 commit 8ff282e

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

wix/generic-DataLab.wxs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
<!-- Copyright (c) DataLab Platform Developers, BSD 3-Clause license, see LICENSE file. -->
22
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs"
33
xmlns:ui="http://wixtoolset.org/schemas/v4/wxs/ui">
4-
<Package Name="DataLab" ProductCode="4ad79deb-5cf7-481c-a242-28c66b8a53ef" Language="1033" Version="{version}" Codepage="1252" Manufacturer="DataLab Platform Developers" UpgradeCode="538c2966-2bcd-4bd4-b20a-9acb161a1614" InstallerVersion="200" Scope="perUserOrMachine">
5-
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
4+
<Package Name="DataLab" ProductCode="b9f2e8d4-7c3a-4f1b-9e6d-5a8c2f1b4e9a" Language="1033" Version="{version}" Codepage="1252" Manufacturer="DataLab Platform Developers" UpgradeCode="e7a3f5c1-9d84-4b2a-a6f1-2c5d8e9b7a31" InstallerVersion="200" Scope="perUserOrMachine">
5+
<Upgrade Id="e7a3f5c1-9d84-4b2a-a6f1-2c5d8e9b7a31">
6+
<UpgradeVersion Minimum="1.0.0" Maximum="{version}" IncludeMinimum="yes" IncludeMaximum="no" OnlyDetect="no" Property="PREVIOUSVERSIONSINSTALLED" />
7+
<UpgradeVersion Minimum="{version}" OnlyDetect="yes" Property="NEWERVERSIONDETECTED" />
8+
</Upgrade>
9+
<CustomAction Id="PreventDowngrade" Error="A newer version of [ProductName] is already installed." />
10+
<InstallExecuteSequence>
11+
<Custom Action="PreventDowngrade" After="FindRelatedProducts" Condition="NEWERVERSIONDETECTED" />
12+
<RemoveExistingProducts After="InstallInitialize" />
13+
</InstallExecuteSequence>
614
<Icon Id="DataLab.exe" SourceFile=".\resources\DataLab.ico" />
715
<Icon Id="DataLabResetIcon" SourceFile=".\resources\DataLab-Reset.ico" />
816
<WixVariable Id="WixUILicenseRtf" Value=".\wix\license.rtf" />
@@ -28,12 +36,12 @@
2836
<Custom Action="PreviousVersionFoundMsg" After="CostInitialize" Condition="NSIS_UNINSTALL_STRING" />
2937
</InstallUISequence>
3038
<StandardDirectory Id="ProgramFilesFolder">
31-
<Directory Id="INSTALLFOLDER" Name="DataLab">
39+
<Directory Id="INSTALLFOLDER" Name="{install_folder_name}">
3240
<!-- Automatically inserted directories -->
3341
</Directory>
3442
</StandardDirectory>
3543
<StandardDirectory Id="ProgramMenuFolder">
36-
<Directory Id="ApplicationProgramsFolder" Name="DataLab" />
44+
<Directory Id="ApplicationProgramsFolder" Name="{display_folder_name}" />
3745
</StandardDirectory>
3846
</Fragment>
3947
<Fragment>
@@ -43,11 +51,11 @@
4351
</Component>
4452
<!-- Automatically inserted components -->
4553
<Component Id="PC_Shortcuts" Directory="ApplicationProgramsFolder" Guid="858c3c36-978e-4edb-a2c3-cf5c91588bcf">
46-
<Shortcut Id="ApplicationStartMenuShortcut" Name="DataLab" Description="DataLab" Target="[INSTALLFOLDER]\DataLab.exe" WorkingDirectory="INSTALLFOLDER" />
47-
<Shortcut Id="ResetApplicationStartMenuShortcut" Name="Reset DataLab" Description="Resets DataLab configuration" Target="[INSTALLFOLDER]\DataLab.exe" Arguments="--reset" WorkingDirectory="INSTALLFOLDER" Icon="DataLabResetIcon" />
48-
<Shortcut Id="UninstallProductShortcut" Name="Uninstall DataLab" Description="Uninstalls DataLab" Target="[System64Folder]msiexec.exe" Arguments="/x [ProductCode]" WorkingDirectory="INSTALLFOLDER" />
54+
<Shortcut Id="ApplicationStartMenuShortcut" Name="{display_folder_name}" Description="{display_folder_name}" Target="[INSTALLFOLDER]\DataLab.exe" WorkingDirectory="INSTALLFOLDER" />
55+
<Shortcut Id="ResetApplicationStartMenuShortcut" Name="Reset {display_folder_name}" Description="Resets {display_folder_name} configuration" Target="[INSTALLFOLDER]\DataLab.exe" Arguments="--reset" WorkingDirectory="INSTALLFOLDER" Icon="DataLabResetIcon" />
56+
<Shortcut Id="UninstallProductShortcut" Name="Uninstall {display_folder_name}" Description="Uninstalls {display_folder_name}" Target="[System64Folder]msiexec.exe" Arguments="/x [ProductCode]" WorkingDirectory="INSTALLFOLDER" />
4957
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall" />
50-
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\DataLab" Name="installed" Type="integer" Value="1" KeyPath="yes" />
58+
<RegistryValue Root="HKCU" Key="Software\[Manufacturer]\{install_folder_name}" Name="installed" Type="integer" Value="1" KeyPath="yes" />
5159
</Component>
5260
</ComponentGroup>
5361
</Fragment>

wix/makewxs.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ def make_wxs(product_name: str, version: str) -> None:
6464
version_msi = re.sub(r"\.dev\d+$", ".0", version_msi)
6565
version_msi = re.sub(r"(rc|a|b)\d+$", ".0", version_msi)
6666

67+
# Generate version-based names for folders
68+
# Extract major.minor version (e.g., "1.0" from "1.0.0")
69+
major_minor = ".".join(version_msi.split(".")[:2])
70+
# Extract major version for technical folder name (e.g., "1" from "1.0.0")
71+
major_version = version_msi.split(".")[0]
72+
# Technical folder name: "DataLab_v1"
73+
install_folder_name = f"{product_name}_v{major_version}"
74+
# User-friendly folder name: "DataLab 1.0"
75+
display_folder_name = f"{product_name} {major_minor}"
76+
6777
wix_dir = osp.abspath(osp.dirname(__file__))
6878
proj_dir = osp.join(wix_dir, os.pardir)
6979
dist_dir = osp.join(proj_dir, "dist", product_name)
@@ -152,6 +162,8 @@ def make_wxs(product_name: str, version: str) -> None:
152162
wxs = insert_text_after(dir_str, "<!-- Automatically inserted directories -->", wxs)
153163
wxs = insert_text_after(comp_str, "<!-- Automatically inserted components -->", wxs)
154164
wxs = wxs.replace("{version}", version_msi)
165+
wxs = wxs.replace("{install_folder_name}", install_folder_name)
166+
wxs = wxs.replace("{display_folder_name}", display_folder_name)
155167
with open(output_path, "w", encoding="utf-8") as fd:
156168
fd.write(wxs)
157169
print("Successfully created:", output_path)

0 commit comments

Comments
 (0)