As you already know, SharpSetup is built on Windows Installer (WI) technology. WI installation package (also known as MSI database) can be built using various tools. While SharpSetup libraries used in the Gui project make no assumptions on how the MSI file has been built the default when creating new SharpSetup solution is to use Windows Installer XML toolset (WiX). You probably know some WiX basics so this article will focus on areas that are specific to SharpSetup.

The most important difference between creating installer using SharpSetup and creating it using WiX alone is the fact that when using SharpSetup your WiX files do not contain definition of user interface. This is because the GUI part is delegated to the Gui project written in .NET using C# and WinForms.

When you create new SharpSetup solution a WiX project named Package is created for you (see screenshot). It contains 4 files: default.wxl, language-code.wxl, Product.Uninstaller.wxi and Product.wxs. First two files are translation files which map identifiers used in *.wxs and *.wxi files into human readable strings (used for feature names, feature descriptions, application name and other user visible messages). default wxs file is used for default culture (en-US) and language-code.wxl (eg. en-GB.wxl) is used for culture you selected during solution creation. You can also add your own translation files. To simplify the task in the Add New Item dialog you can select "Sample WiX/SharpSetup Localization File" and enter name such as de-DE.wxl (culture code + wxl extension). This will create sample file with correct Culture and Codepage attribute values and strings such as LANGUAGE, CULTURE and APPNAME that are needed by SharpSetup.

Next file (Product.Uninstaller.wxi) is a file that contains WiX code for installing uninstaller for your application along with shortcuts and Add/Remove Programs (ARP) registry entries. The section that you might be interested in is the AddRemovePrograms component. While common changes (such as application version changes) do not require touching this code you might be interested in adding other properties accepted by ARP dialog (also knows as Programs and Features dialog) such as HelpLink, DisplayIcon, etc.

Last file in the Package project (Product.wxs) is the most important one - it is the one you will be modifying the most. The first few lines define constants important for the whole package (such as AppCode, AppVersion, AppManufacturer). Next, basic information (product name, language, icon, media, default install level) about MSI package is defined. It is followed by definition of Program menu folder for your program and inclusion of Product.Uninstaller.wxi file. Remaining part of the file has two sections containing feature and directory/component definitions. Even though component, directory and feature definitions may appear in any order they are logically distinct concepts.

Feature is a logical group of components visible to the user under common name. Features apart from unique identifier have such properties as name, description, level or display attribute. Features may also contain sub-features therefore creating a feature tree. You can add components to a feature by using ComponentRef and ComponentGroupRef tags with appropriate identifier. As there are typically only a few features per installation package it is relatively easy to define them by hand.

Components, most commonly, contain files and registry entries. As even for a small product the number of required files and registry entries may be counted in hundreds SharpSetup provides a tool that helps defining components. If you right click on *.wxs file in Solution explorer and select Add Component menu item an Add Component Dialog will appear. This way you may quickly add files and directories to your WiX project. Depending on the settings WiX Component tag or WiX Fragment, Component and ComponentGroup tags will be generated. Note however that you have to add those components to feature(s) manually. Files you reference in your components must be accessible during SharpSetup solution build time. Typically your installer will be built on multiple computers (development computers, build servers) so referencing files by absolute path names is usually not an option. Sample SharpSetup solution follows a convention of placing input files in ProductBuild subdirectory of solution directory.

This article should get you started with editing files belonging to Package project in freshly created SharpSetup solution. Next articles will describe IntermediateBootstrapper, Translation and Assembler projects. Stay tuned!

Previous in series: Installer GUI design

Next in series: SharpSetup bootstrappers