Arghhhhh!! to Phew!!, Rendezvous with Using Wix from Command Line

This article aims to bestow some knowledge on how to generate an .msi package using Wix toolset from command line, and hence also aims to perform a noble cause of saving some eyes from getting strained and some hair falling off of the scalp 
While an effort to build a “Continuous Delivery Using Build Pipelines With Jenkins ”, we came across a hurdle of how to generate a .msi package using wix from command line. And it took real hard work of couple of days to get the solution. Mostly the credit for toiling so hard goes to unconsolidated information scattered at far of places on the web. Hence this article aims to provide a single point of source of wisdom for tackling this problematic beast. Ok Enough babbling! Let us get to work.

Step 1: Build the solution from command line to generate bin/Debug output:



Build your solution using msbuild command, targeting your solution file.
Note : /m option builds multiple projects in parallel.Step1

Step 2: Setup environment variable path for Wix directory or else navigate to Wix directory from your command promt

Step 3: Harvest the directories in order to output fragment file(s):Step3

heat.exe dir : followed by Target folder, in my case bin\Debug folder after a successful build of my solution.
-dr INSTALLFOLDER : Makes sure the generated .wxs file has Directory=”INSTALLFOLDER” tag.

-cg : The component group name you want to give.

A new fragment file will be created at location ..\Setup

Step 4: Use wix Candle.exe to compile the generated .wxs file and generate .wixobj files.Step4

In our scenario, we had a pre-written Product.wxs file, which is used along with generated fragment.wxs file to give Product.wixobj and fragment.wixobj files.

Step 5:Use light.exe to generate the final msi packageStep5

And finally we use light.exe to generate .msi setup, targeting our step 4 generated wixobj files and our bin\Debug folder.

Hope you find this article helpful!