diff --git a/node_modules/app-builder-lib/templates/msi/template.xml b/node_modules/app-builder-lib/templates/msi/template.xml
index 2d5cd3c..9bf447e 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 @@
 <?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"/>
@@ -13,19 +16,50 @@
 
       So, AllowSameVersionUpgrades="yes" allows to build and test MSI with the same version, and previously installed app will be removed.
     -->
-    <MajorUpgrade AllowSameVersionUpgrades="yes" DowngradeErrorMessage='A newer version of "[ProductName]" is already installed.'/>
+    <!-- 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 AllowDowngrades='yes'/>
     <MediaTemplate CompressionLevel="${compressionLevel}" EmbedCab="yes"/>
   
     <Property Id="WIXUI_INSTALLDIR" Value="APPLICATIONFOLDER"/>
     <Property Id="ApplicationFolderName" Value="${installationDirectoryWixName}"/>
     <Property Id="WixAppFolder" Value="WixPerUserFolder"/>
     <Property Id="DISABLEADVTSHORTCUTS" Value="1"/>
+    <Property Id="REINSTALLMODE" Value="amus" />
+    <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}"/>
     {{ } -}}
 
+    <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="WixCloseApplications" Before="InstallValidate"/>
+      <Custom Action="WixCloseApplicationsDeferred" 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 +76,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 +115,7 @@
       </UI>
     {{ } -}}
 
+    <Directory Id="resourcesDir" Name="APPLICATIONFOLDER:\resources\"/>
     <Directory Id="TARGETDIR" Name="SourceDir">
       <Directory Id="${programFilesId}">
         {{ if (menuCategory) { }}
@@ -110,6 +146,10 @@
     {{-dirs}}
 
     <ComponentGroup Id="ProductComponents" Directory="APPLICATIONFOLDER">
+      <Component Directory="resourcesDir">
+        <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}}
     </ComponentGroup>
   </Product>
