Create an installer in WiX to distribute upgraded applications

Page creation date :

environment

Visual Studio
  • Visual Studio Community 2017
  • Visual Studio Community 2019
WiX Toolset
3.11.2

※ It works in other versions, but it is unconfirmed

At first

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.

Product.wxs changes

Launch Visual Studio and open the project (solution file) that you have already created.

Open Product.wxs and change the following parameters:

Wix/Product/@Id

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" />

Wix/Product/@Version

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="1.8.0.0" />

Wix/Product/@UpgradeCode

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">

Wix/Product/MajorUpgrade/@DowngradeErrorMessage

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] がインストールされているため、インストールを中断します。" />

image

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.

image

Update license.rtf

If you want to change the license agreement displayed on the installation screen, please change the contents.

image

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.

Launch WixEdit.

image

Open the Product.wxs file.

image

image

Select Files from the icon on the left. Delete the folders below ProgramFilesFolder.

image

Right-click on the ProgramFilesFolder folder and select Import Folder.

image

Select the folder where you want to install the files.

image

A set of files is added to the tree.

image

In order to associate with other parameters, select the added folder and set "Id" back to "INSTALLFOLDER".

image

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)

image

select "New" and "Shortcut" from the right-click menu of the exe file.

image

When Shortcut is added, select it and right-click the blank to add the property.

image

Add the following parameters: (Change the unique name to match the program.)

Attribute value
Id LITTLESAVIORTRIAL. EXE_shortcut
Name Little Saber Trial
Directory ProgramMenuDir
WorkingDirectory INSTALLDIR
Icon LITTLESAVIOR. ICO
IconIndex 0
Advertise yes

image

Then select the "Feature" tab.

Add any files you have added, and delete any files you no longer need.

image

image

image

If you're having trouble working with the UI, you can edit the XML directly.

image

Save.

image

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.