Skip to content

Commit

Permalink
Cherry-pick of #3237, #3238, #3239 to release-5.9 (#3247)
Browse files Browse the repository at this point in the history
* [MM-61994] Fix UpgradeCode to use the old one, allow MSI to uninstall both (#3237)

Co-authored-by: Devin Binnie <[email protected]>

* [MM-62029] Require MSIINSTALLPERUSER for auto update to work (#3239)

Co-authored-by: Devin Binnie <[email protected]>

* [MM-60416] Check for the presence of the EXE uninstaller before trying to run it (#3238)

Co-authored-by: Devin Binnie <[email protected]>

---------

Co-authored-by: Devin Binnie <[email protected]>
  • Loading branch information
devinbinnie and Wipeout55 authored Dec 9, 2024
1 parent 6fd806c commit e38e42f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
3 changes: 2 additions & 1 deletion electron-builder.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@
"include": "scripts/installer.nsh"
},
"msi": {
"additionalWixArgs": ["-ext", "WixUtilExtension"]
"additionalWixArgs": ["-ext", "WixUtilExtension"],
"upgradeCode": "{8523DAF0-699D-4CC7-9A65-C5E696A9DE6D}"
},
"rpm": {
"fpm": ["--rpm-rpmbuild-define", "_build_id_links none"]
Expand Down
36 changes: 29 additions & 7 deletions patches/app-builder-lib+24.13.3.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/node_modules/app-builder-lib/templates/msi/template.xml b/node_modules/app-builder-lib/templates/msi/template.xml
index 2d5cd3c..92a0556 100644
index 2d5cd3c..3c2d128 100644
--- a/node_modules/app-builder-lib/templates/msi/template.xml
+++ b/node_modules/app-builder-lib/templates/msi/template.xml
@@ -1,5 +1,8 @@
Expand All @@ -12,7 +12,29 @@ index 2d5cd3c..92a0556 100644
<!-- https://blogs.msdn.microsoft.com/gremlininthemachine/2006/12/05/msi-wix-and-unicode/ -->
<Product Id="*" Name="${productName}" UpgradeCode="${upgradeCode}" Version="${version}" Language="1033" Codepage="65001" Manufacturer="${manufacturer}">
<Package Compressed="yes" InstallerVersion="500"/>
@@ -26,6 +29,27 @@
@@ -13,6 +16,10 @@

So, AllowSameVersionUpgrades="yes" allows to build and test MSI with the same version, and previously installed app will be removed.
-->
+ <!-- Remove versions of newer MSI using the wrong UpgradeCode -->
+ <Upgrade Id="{0F183CAA-DF79-5400-A71F-684F563AF31C}">
+ <UpgradeVersion Property="PREVMSIINSTALLER" IncludeMaximum="yes" Maximum="${version}" MigrateFeatures="yes" OnlyDetect="no"/>
+ </Upgrade>
<MajorUpgrade AllowSameVersionUpgrades="yes" DowngradeErrorMessage='A newer version of "[ProductName]" is already installed.'/>
<MediaTemplate CompressionLevel="${compressionLevel}" EmbedCab="yes"/>

@@ -20,12 +27,38 @@
<Property Id="ApplicationFolderName" Value="${installationDirectoryWixName}"/>
<Property Id="WixAppFolder" Value="WixPerUserFolder"/>
<Property Id="DISABLEADVTSHORTCUTS" Value="1"/>
+ <Property Id="EXEINSTALLEREXISTS">
+ <DirectorySearch Path="[LocalAppDataFolder]\Programs\mattermost-desktop" Depth="0">
+ <FileSearch Id="SearchEXEUninstaller" Name="Uninstall ${productName}.exe" />
+ </DirectorySearch>
+ </Property>

{{ if (iconPath) { }}
<Icon Id="${iconId}" SourceFile="${iconPath}"/>
<Property Id="ARPPRODUCTICON" Value="${iconId}"/>
{{ } -}}

Expand All @@ -34,34 +56,34 @@ index 2d5cd3c..92a0556 100644
+ <InstallExecuteSequence>
+ <Custom Action="WixCloseApplications" Before="InstallValidate"/>
+ <Custom Action="WixCloseApplicationsDeferred" After="InstallInitialize"/>
+ <Custom Action="removeExeInstaller" After="InstallInitialize"/>
+ <Custom Action="removeExeInstaller" After="RemoveExistingProducts">EXEINSTALLEREXISTS</Custom>
+ </InstallExecuteSequence>
+
{{ if (isRunAfterFinish) { }}
<CustomAction Id="runAfterFinish" FileKey="mainExecutable" ExeCommand="" Execute="immediate" Impersonate="yes" Return="asyncNoWait"/>
{{ if (!isAssisted) { }}
@@ -42,6 +66,7 @@
@@ -42,6 +75,7 @@
<Property Id="ALLUSERS" Secure="yes" Value="2"/>
{{ } -}}
<Property Id="MSIINSTALLPERUSER" Secure="yes" Value="1"/>
+ <Property Id="DISABLEAUTOUPDATE" Value="0"/>

{{ if (isAssisted) { }}
<WixVariable Id="WixUISupportPerUser" Value="1" Overridable="yes"/>
@@ -80,6 +105,7 @@
@@ -80,6 +114,7 @@
</UI>
{{ } -}}

+ <Directory Id="resourcesDir" Name="APPLICATIONFOLDER:\resources\"/>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="${programFilesId}">
{{ if (menuCategory) { }}
@@ -110,6 +136,10 @@
@@ -110,6 +145,10 @@
{{-dirs}}

<ComponentGroup Id="ProductComponents" Directory="APPLICATIONFOLDER">
+ <Component Directory="resourcesDir">
+ <Condition>(NOT ALLUSERS = 1) AND DISABLEAUTOUPDATE = 0</Condition>
+ <Condition>(NOT ALLUSERS = 1) AND MSIINSTALLPERUSER = 1 AND DISABLEAUTOUPDATE = 0</Condition>
+ <File Name="app-update.yml" Source="$(var.appDir)\..\msi-app-update.yml" ReadOnly="yes" KeyPath="yes"/>
+ </Component>
{{-files}}
Expand Down

0 comments on commit e38e42f

Please sign in to comment.