Creating first installer package (msi file)
Windows Installer XML (WiX) is a free XML markup from Microsoft that is
used to author installation packages for Windows-based software. The underlying
technology is Windows Installer, which is the established standard for
installing desktop-based applications to any Windows operating system.
Creating
a windows Installer, or MSI package, has always been a challenging task. The package is
actually a relational database that describes how the various components of an
application should be unpacked and copied to the end user's computer.
Following
is a list of features that we get when created a Windows installer package (.msi)
with WiX,
· All of our executable files can be packaged
into one bundle, simplifying deployment.
· Software is automatically registered with Add/Remove Programs.
· Windows takes care of uninstalling all of the components that make up our product when
the user chooses to do so.
· If files of software are accidently removed,
those can be replaced by right-clicking on the MSI file and selecting Repair.
· We can create different versions of our
installer and detect which version has been installed.
· We can create patches to update only specific
areas of application.
· If something went wrong while installing
software, the end user's computer can be rolled back to a previous state.
. We can create Wizard style dialogs to guide
the user through the installation.
Before going further,
first we need to get all prerequisites to create our first installer package (msi)
using wix. Follow the below steps,
- Install VS2005 or later versions (for expressions we don’t get intellisense support for WIX)
- Install ProjectAggregator 2. Get it from here, http://wix.sourceforge.net/redist/ProjectAggregator2.msi
- Download latest(wix 3.7) WIX Toolset from http://wixtoolset.org/
Click on Install button then, it does
installation for us. This installs all of the required files needed to build
WiX projects. We also get the WiX SDK documentation and the settings for Visual Studio IntelliSense, highlighting and project templates.
After we have installed
WiX, should see a new category of project types in Visual Studio labeled under
the title Windows Installer XML, as
shown in the following image,
Below are the new
project templates:
Ø
Setup
Project: Creates a Windows Installer package from one or more WiX source
files
Ø
Merge
Module Project: Creates a merge module (MSM) file
Ø
Setup
Library Project: Creates a .wixlib
library
Ø
Bootstrapper
Project: Creates a prerequisite bootstrapper
Ø
C# Custom
Action Project: Creates a .NET custom action in C#
Ø
C++
Custom Action Project: Creates an unmanaged C++ custom action
Ø
VB Custom
Action Project: Creates a VB.NET custom action
Using these templates is
easier than creating the files on our own with a text editor. Start creating our own MSI installer; select the
template Setup Project from visual
studio.
First thing, we want to
do is set the amount of information that we'd like to see when compiling and linking
the project, and how non-critical messages are treated. Right click on wix
project in Solution Explorer and select Properties and follow the below screen,
Here we're selecting the
level of messages that we'd like to see.
- Warning Level to Pedantic: To see all warnings and messages
- Check the Verbose
output: to get even more information.
Another feature of WiX is
its ability to run validity checks on the MSI package. Windows Installer uses a
suite of tests called Internal
Consistency Evaluators (ICEs) for this. These checks ensure that the
database as a whole makes sense and that the keys on each table join correctly.
From project settings in
Visual Studio, we can choose to suppress specific ICE tests using the Tools Setting page as shown in the
following screenshot.
In this example, ICE
test 100 is being suppressed. We can specify more than one test by separating
them with semicolons as ICE100;ICE101
Now start creating our
first installer,
- Open Visual Studio
- Select File | New | Project | Windows Installer XML | Setup Project.
This will create a
project with a single .wxs file (wix
source). Visual Studio will usually call this file Product.wxs, but name can be anything as long as it ends with .wxs. Default file must have the
following XML Elements,
- An XML declaration
- Wix element - serves as the root element in XML document
- Product element - child to the Wix element, but all other elements are children to it
- A Package element
- MediaTemplate element
- One Directory element with at least one child Component element
- One Feature element
We will check more details about these
elements later in these series of tutorials.
Now build our wix project and we can see the .msi file created for us under our
configured output folder as shown below.
Now we are done with creation of installer
(.msi) and we can use it for our application installation. The installer we
created has nothing to install but, we will see in later articles how to add
required application files to installer.
Comments
Post a Comment