Fixes for the MSI installer (#3043)

* Run uninstaller for EXE synchronously so that it doesn't try to uninstall while also installing

* Display error message before running MSI installer to close the application manually
This commit is contained in:
Devin Binnie 2024-05-28 17:04:13 -04:00 committed by GitHub
parent e1a75deb4f
commit 39a2d863f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 36 additions and 7 deletions

View file

@ -180,6 +180,9 @@
"uninstallDisplayName": "${productName}",
"include": "scripts/installer.nsh"
},
"msi": {
"additionalWixArgs": ["-ext", "WixUtilExtension"]
},
"rpm": {
"fpm": ["--rpm-rpmbuild-define", "_build_id_links none"]
}

View file

@ -1,20 +1,46 @@
diff --git a/node_modules/app-builder-lib/templates/msi/template.xml b/node_modules/app-builder-lib/templates/msi/template.xml
index 2d5cd3c..04ed672 100644
index 2d5cd3c..92a0556 100644
--- a/node_modules/app-builder-lib/templates/msi/template.xml
+++ b/node_modules/app-builder-lib/templates/msi/template.xml
@@ -26,6 +26,11 @@
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
-<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
+<Wix
+ xmlns="http://wixtoolset.org/schemas/v4/wxs"
+ xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util"
+>
<!-- 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 @@
<Property Id="ARPPRODUCTICON" Value="${iconId}"/>
{{ } -}}
+ <CustomAction Id="removeExeInstaller" Directory="APPLICATIONFOLDER" ExeCommand="[APPLICATIONFOLDER]Uninstall ${productName}.exe /S" Execute="immediate" Impersonate="yes" Return="asyncWait"/>
+ <util:CloseApplication
+ Id="closeApplication"
+ Description="Mattermost is still running. Please ensure to manually close before continuing installation."
+ Target="Mattermost.exe"
+ RebootPrompt="no"
+ PromptToContinue="yes"
+ />
+ <CustomAction
+ Id="removeExeInstaller"
+ Directory="APPLICATIONFOLDER"
+ ExeCommand="[APPLICATIONFOLDER]Uninstall ${productName}.exe /S"
+ Execute="immediate"
+ Impersonate="yes"
+ Return="ignore"
+ />
+ <InstallExecuteSequence>
+ <Custom Action="removeExeInstaller" Before="InstallInitialize"/>
+ <Custom Action="WixCloseApplications" Before="InstallValidate"/>
+ <Custom Action="WixCloseApplicationsDeferred" After="InstallInitialize"/>
+ <Custom Action="removeExeInstaller" After="InstallInitialize"/>
+ </InstallExecuteSequence>
+
{{ if (isRunAfterFinish) { }}
<CustomAction Id="runAfterFinish" FileKey="mainExecutable" ExeCommand="" Execute="immediate" Impersonate="yes" Return="asyncNoWait"/>
{{ if (!isAssisted) { }}
@@ -42,6 +47,7 @@
@@ -42,6 +66,7 @@
<Property Id="ALLUSERS" Secure="yes" Value="2"/>
{{ } -}}
<Property Id="MSIINSTALLPERUSER" Secure="yes" Value="1"/>
@ -22,7 +48,7 @@ index 2d5cd3c..04ed672 100644
{{ if (isAssisted) { }}
<WixVariable Id="WixUISupportPerUser" Value="1" Overridable="yes"/>
@@ -80,6 +86,7 @@
@@ -80,6 +105,7 @@
</UI>
{{ } -}}
@ -30,7 +56,7 @@ index 2d5cd3c..04ed672 100644
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="${programFilesId}">
{{ if (menuCategory) { }}
@@ -110,6 +117,10 @@
@@ -110,6 +136,10 @@
{{-dirs}}
<ComponentGroup Id="ProductComponents" Directory="APPLICATIONFOLDER">