Create a smart deployment packaging with WiX 3.10 for Visual Studio 2015

Many people are keen about using WIX to create setup package and I would like to share my personal experience using WIX with GrabCaster.

I’m a very lazy developer, well I like writing code, but I hate writing documentation and I really hate to repeat the same operation every time.
I’m not a “C# Guru” or a  “lambda extremist” but I like to find the smarter way to solve my development problems and WIX contains a lot of useful tools to make my life better.

My idea was “one click and development package ready” so I started study around this problem, below my personal solution.

You can find all the source code in GitHub in the GrabCaster.Framework repo

The GrabCaster setup contains everything I need like dialog boxes , icons and so on and I’m now able to create this package during the build, but the crucial point was one only, I don’t want to change any WIX setup file because I add a new DLL or component, I want everything automatic.

WIX contains a crazy useful harvet tool named heat.exe, this executable is able to generate your WIX deployment packages automatically and using a directory as your “deployment image”.

First of all I created my batch script to create my deploy directory I named it PrepareDeployPackage.cmd.

I created the  WIX project in the GrabCaster solution, you can refer to this my post to understand how to get WIX and install it.

Right click on the WIX project file and in the Pre-Build Events I added my scripts where:

setup1

  • call “$(Solutiondir)\Development Script\PrepareDeployPackage.cmd”
    • call my script to create and copy the directories and files
  • “%WIX%\bin\heat.exe” dir “$(Solutiondir)Setup\bin\$(Configuration)\Deploy” -srd -dr INSTALLDIR_GRABCASTER -sfrag -sreg -cg SourceComponentGroup -var var.SourcePath -ag -out “$(SolutionDir).\Setup\SourceComponents.wxs”
    • execute the heat.exe to generate the SourceComponents.wxs to create the WIX package.

Interesting is the %WIX% macro to specify the WIX installation directory.
The most importa varibles are INSTALLDIR_GRABCASTER, this is your installation folder variable, to be clear the “program file\your program” forlder, you will use that in the WIX setting file and it is correlated with the SourceComponents.wxs file too.

SourceComponentGroup is the componet group name containing your files.

Very important and useful the macros like $(Solutiondir) and $(Configuration) to be dynamic.

You can find more detail regarding the harvest parameter in the WIX documentation.

In the Product.ws file I added everything I need to create my msi package, below the details:

Two WIX variable for the images and icons

s2

The two dialog boxes, the WelcomeDlg and InstallDirDlg are  WIX variable and you can find all of them in the WIX documentation, please have a look the INSTALLDIR_GRABCASTER variable, this is the most important correlation inside the setting s file.

s33

The features with the SourceComponentGroup we used n the script line.

s4

The directory structure, please note the INSTALLDIR_GRABCASTER variable, I used the desktop folder for the shortcut icon.

s5

The last important part is the directory reference detail which contain all we need for the directories references folder, icons and uninstall feature.

s6

For more details you can find you can find all the source code in GitHub in the GrabCaster.Framework repo.

 

Related blog posts