Create an installer in WiX to distribute upgraded applications
- Visual Studio
- Visual Studio Community 2017
- Visual Studio Community 2019
- WiX Toolset
※ It works in other versions, but it is unconfirmed
Learn how to create an installer when upgrading an application. It is based on the article on the procedure of creating the first version of the installer. There may be differences in how you make it.
If you want to keep the previous project before updating, back it up in some way, such as copying the file.
Preparation in advance
- The first version of the installer has been created and the project exists.
About upgrade types
There are several upgrade methods for upgrading as mentioned in the following article. The procedure here describes a major upgrade. Unless you have special circumstances, this is fine.
Launch Visual Studio and open the project (solution file) that you have already created.
Open Product.wxs and change the following parameters:
Replace this ID with the new GUID if you are doing a Major Upgrade.
Minor upgrades and small upgrades do not need to be changed, but are beyond the scope of this document.
<Wix> <Product Id="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" />
It is used to determine if it is a newer version during installation, so increase the number than the previous version. There are four numbers of "major version.minor version.revision.build", There are three things that determine whether a version has gone up: major version.minor version.revision.
As the number increases, it can be any number, but basically it is safe to match it with the version of the application.
<Wix> <Product Version="220.127.116.11" />
This code identifies whether it is a version upgrade to the same application. Therefore, if you want to upgrade with an overwriting installation, do not change it from the code when it was first released.
Conversely, if you want to install it as a separate application although it is a version upgrade, replace it with a new GUID.
<Wix> <Product UpgradeCode="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX">
This message is displayed when you start the old installer with a newer version of the application installed. It is used for older versions of the installer, so if you have already set up messages in previous versions, you don't need to change them. If you want to change it, please rewrite it.
If you want to display Japanese, you need to set the attributes of Languages and SummaryCodepage to Japanese (Japanese support is introduced in a separate article). ProductName is replaced by the product name.
<Wix> <Product> <MajorUpgrade DowngradeErrorMessage="すでに新しいバージョンの [ProductName] がインストールされているため、インストールを中断します。" />
How to install files
As with when you created the installer for the first time Please re-enter the new program and related files. Delete files that you no longer use.
If you want to change the license agreement displayed on the installation screen, please change the contents.
Product.wxs installation file information update
* You do not need to work on this item if the file or folder configuration to be installed has not changed at all from the previous version.
The high-level task of this item is to remove and recreate all previous file installation settings. If you've only added or decreased one file, it might be faster to play with product.wxs code directly.
Open the Product.wxs file.
Select Files from the icon on the left. Delete the folders below ProgramFilesFolder.
Right-click on the ProgramFilesFolder folder and select Import Folder.
Select the folder where you want to install the files.
A set of files is added to the tree.
In order to associate with other parameters, select the added folder and set "Id" back to "INSTALLFOLDER".
Create a shortcut for the Start menu. Because this shortcut creation work becomes the same work every time, It may be faster to save the XML code and paste it later. (Selection part of the image below)
select "New" and "Shortcut" from the right-click menu of the exe file.
When Shortcut is added, select it and right-click the blank to add the property.
Add the following parameters: (Change the unique name to match the program.)
|Name||Little Saber Trial|
Then select the "Feature" tab.
Add any files you have added, and delete any files you no longer need.
If you're having trouble working with the UI, you can edit the XML directly.
Build and execution confirmation
Build it in Visual Studio and create an installer.
Run the new version of the installer with the previous version installed and make sure it is overwritten and installed.
Also, try to make sure that you cannot install the previous version of the installer when you run the installer while you have a new version installed.