This repository contains samples I use for Windows Installer XML (WiX) workshops and trainings.
If you will participate in one of my trainings and you are looking for a list of software and tools you are going to need, please read the corresponding blog article.
Although my main business is our SaaS solution time cockpit, I also offer trainings and workshops on various software development topics. MSI with WiX is one of them. If you like my samples and slides and you want to get a jump-start by doing a workshop with me, please contact me at [email protected].
Every now and then I write blog posts with detailed information about certain topics. Here are links to WiX-related posts (might be out of date, please check http://www.software-architects.com for a list of all available posts):
Feel free to download my WiX slidedeck.
- Homepage of the WiX Toolset
- WiX Docs (v3.x)
- Windows Installer Docs on MSDN
- Great Book: Ramirez, Nick: WiX 3.6: A Developer's �Guide to Windows Installer XML, Packt Publishing (Sponsored Amazon Link)
- Windows Dev Center (Desktop Development)
Demo installer for learning WiX basics. It covers:
- Basic structure of WiX files in Product.wxs
(e.g.
Product,Package,MediaTemplate,Directorystructure, Components, Shortcuts, Registry Values, Features, references to built-in UI, etc.) - Signing of MSI packages including generation of dev certificates in SignMSI.cmd
Another demo for learning WiX basics. In addition to WiX Basics it covers:
- Usage of project references in WiX projects (see Product.wxs):
<File Id="FILE_DotNetToolExe" Source="$(var.DotNetTool.TargetPath)" KeyPath="yes" /> - Binder variables (see Product.wxs):
Version="!(bind.fileVersion.FILE_DotNetToolExe)" - Preprocessor (see Product.wxs):
<?if $(var.ProcessorArchitecture)=x64 ?> ... <?else ?> ... <?endif ?>
Another demo for learning WiX basics. In addition to WiX Basics it covers registry searches (see Product.wxs).
This sample contains a composite WPF application that uses MEF (Managed Extensibility Framework) for loading extensions and Sandcastle for generating SDK documentation (see CompositeWpfApp.Documentation).
The sample contains two setup projects. CompositeWpfApp.Install generates a single installer. CompositeWpfApp.InstallCab generates an installer with multiple CAB files. See blog article Shipping large MSI installers via Azure Blob Storage for how to deploy MSI packages with multiple CAB files via web and Microsoft Azure.
The sample also contains a Burn bootstrapper sample in CompositeWpfApp.Bootstrapper. It create two separate MSI files (one for the application, one for the extension) and chains them into a single installer exe (see Bundle.wxs). It uses the built-in UI of Burn.
This sample demonstrate how to create a WiX setup installing a COM DLL. It also comes with a simple COM server written in C# that can be used for experiments (see SimpleComServer.cs).
The sample harvests the COM DLL during compilation. Check project file if you want to see how this is done. The installer itself is therefore quite simple.
<ItemGroup>
<HarvestFile Include="$(ProjectDir)..\ComDllToRegister\bin\$(Configuration)\ComDllToRegister.dll">
<ComponentGroupName>ComDll</ComponentGroupName>
<DirectoryRefId>INSTALLFOLDER</DirectoryRefId>
<Link>ComDllToRegister.dll</Link>
<PreprocessorVariable>var.ComDllToRegister.TargetDir</PreprocessorVariable>
<SuppressRootDirectory>true</SuppressRootDirectory>
</HarvestFile>
</ItemGroup>I have created this sample to demonstrate the creation of MSI packages for installing Windows Services.
The sample contains a simple demo service written in C#. This demo service just writes into Windows Eventlog on a regular basis (see EventLoggingService.cs).
The installer used to install the demo service is shown in Product.wxs.
<Component Id="CMP_Service" Directory="INSTALLFOLDER">
<!-- Install service executable -->
<File Id="FILE_EventLoggingService"
Source="$(var.ServiceToInstall.TargetPath)"
KeyPath="yes" />
<!-- Install service -->
<ServiceInstall Id="InstallELS"
Name="WiXEventLoggingService"
Description="WiX EventLoggingService Sample"
Start="auto"
ErrorControl="normal"
Type="ownProcess"/>
<!-- Set start/stop/remove options -->
<ServiceControl Id="ControllELS"
Name="WiXEventLoggingService"
Start="install"
Stop="both"
Remove="uninstall"
Wait="yes" />
</Component>This is a more advanced WiX sample. It demonstrates the development of a custom action written in C++. The scenario of the sample is a MSI package for installing a Visual Studio Snippet. The target directory is determined by a combination of different custom actions.
A detailed description of the sample can be found at VisualStudioSnippetInstaller.
This is a more advanced WiX sample. It demonstrates the development of a custom action written in C# to validate a given SQL Server name (see CustomAction.cs). If you want to play with it and debug the C# custom action, just add the following two lines to the beginning of the custom action:
Debugger.Launch();
Debugger.Break();The C# custom action is used in the installer Product.wxs. Note that this installer has a custom WiX UI in AdditionalDialog.wxs. It calls into the C# custom action.
This sample consists of two parts. First, Product.wxs
contains an installer that makes a Windows Server 2012
a web server by adding the necessary features using dism.exe.
It does that by using WiX's CAQuietExec64 feature so that the output windows of dism.exe is hidden.
Additionally, this sample shows how to use the WiX WixUtilExtension to find out if IIS is already
installed (IISMAJORVERSION property).
The second part of the sample demonstrates how to install an OWIN ASP.NET web application into IIS using WiX. For that, the sample contains a very simple web site in Startup.cs. The installer Product.wxs performs the following tasks:
- Install the files necessary for the OWIN web site
- Create a new website in IIS (
iis:WebSite) - Create a new virtual directory in the website (
iis:WebDirProperties) - Creates a new application pool for the application (
iis:WebAppPool). Note that the pool is configured to use the v4.0 integrated pipeline so that OWIN will work. - Creates a new application in the website (
iis:WebApplication) and makes it using the new application pool
This sample (Patch) just demonstrates the basics of patch creation with WiX.
This sample demonstrates how to use WPF (Windows Presentation Foundation) to create a custom bootrapper UI using WiX Burn. It consists of the following parts:
- Two installers (FirstInstaller and SecondInstaller) that are chained together in a bootstrapper (see Bundle.wxs).
- A WPF UI for the bootstrapper (see InstallerUI).
Note that:
- The WPF UI uses MEF (Managed Extensibility Framework) for dependency injection
- The WPF UI is built based on the MVVM (Model View ViewModel) design principle using the Microsoft Prism framework
- For demo purposes, the WPF UI handles (nearly) all Burn events and writes them into the log (including parameter
values, see InstallerMainWindowViewModel.cs). If you want to learn about custom bootstrapper UIs, you can run the sample and generate a log file
(
Bootstrapper.exe /log log.txt). Afterwards take a look at the log file. You will see the order and parameters of the Burn events. Play with different scenarios (e.g. install, uninstall, etc.) to understand how the events work.
Tip: A great source for learning how to use WPF together with Burn is the installer of the WiX toolset itself. Grab the sourcecode (see http://wixtoolset.org) and step it through in the debugger (see tip above about how to attach a debugger to C# code running with WiX and/or Burn).