Windows Installer XML (WIX) is a free tool that is use for making Windows installation packages from XML source code.
Straight to Usage
Download Wix from here
If we are using Dotnet 2005, then we need to download one small COM component i.e. ProjectAggregator2.msi. Without this, we cannot install Votive – Wix project and editor package for Visual Studio.
If we want to install Wix first without installing ProjectAggregator2.msi, we will receive the following error message
Note: This is only required for Visual Studio 2005 and not for Visual Studio 2008.
Install ProjectAggregator2.msi first
Install Wix. Click on the exe file
The below window will appear
If you want change the location of your installation file, you can do so by clicking on the Advanced button
Click on the Install button
After successful installation,the below screen will appear
Now let us create a simple WPF application - A Calculator in WPF. The only thing that we will do is we will make a dll file where the business logic will be encapsulated and one picture will be there which will act as a resource file.
So let’s first create a Class library project.
The logic is very simple as expected
public class OurCalciClass
public int MathOperation(int firstNum, int secondNum, string ops)
int result = 0;
case "+": result = firstNum + secondNum; break;
case "-": result = firstNum - secondNum; break;
case "*": result = firstNum * secondNum; break;
case "/": result = firstNum / secondNum; break;
And after compilation, our dll (CalculatorLogic.dll) is ready
Now let’s make a simple UI for the Calculator in WPF. So let’s choose the WPF Application template.
Click on OK and make the following design.
Next add a reference to the CalculatorLogic.dll in the project.And then write the code
private void btnAdd_Click(object sender, RoutedEventArgs e)
txtResult.Text = Result("+");
private void btnSub_Click(object sender, RoutedEventArgs e)
txtResult.Text = Result("-");
private void btnMul_Click(object sender, RoutedEventArgs e)
txtResult.Text = Result("*");
private void btnDiv_Click(object sender, RoutedEventArgs e)
txtResult.Text = Result("/");
private string Result(string ops)
return (objOurCalciClass.MathOperation(Convert.ToInt32(txtNum1.Text), Convert.ToInt32(txtNum2.Text), ops).ToString());
And running the application will yield the desired answer
Now it’s time for adding a project installer. So click on File - > New - > Project. For Project templates, choose WIX as project type and select WIX Project as the project template.
After clicking on the OK button, the following screen will appear
We need to add the Calculator.exe file to the installer. For doing so, we need to uncomment the Component tag.
And has to add the following
<Component Id="ProductComponent" Guid="19685467-f935-4210-a585-a51f9beda693">
<!-- TODO: Insert files, registry keys, and other resources here. -->
<File Id ="CalculatorExe" Source ="C:\CalciUI\CalculatorUI\CalculatorUI\bin\Debug\CalculatorUI.exe"></File>
<File Id ="MyPic" Source ="C:\niladri_biswas.jpg"></File>
<File Id ="CalculatorLogicDll" Source ="C:\CalciLogic\CalculatorLogic\CalculatorLogic\bin\Debug\CalculatorLogic.dll"></File>
That means for every resources added to the project, we need to specify those in the File element.
Next if we want to compile, we will encounter an error
Error 1 Found orphaned Component 'ProductComponent'. If this is a Product, every Component must have at least one parent Feature. To include a Component in a Module, you must include it directly as a Component element of the Module element or indirectly via ComponentRef, ComponentGroup, or ComponentGroupRef elements. C:\FirstWixProject\CalculatorWixProject\CalculatorWixProject\Product.wxs 13 1 CalculatorWixProject
For eliminating this error, remove the comment around ComponenRef element
Build the project. If everything goes smoothly i.e. successful build, then in the Debug directory we will find the MSI installer.
Click on that.
Then go to C:\ProgramFile\CalculatorWixProject
- Wix Tutorial
- Windows Installer XML (WiX) toolset
- Creating an installer using Wix v3.0, Votive, and Visual Studio 2005/2008
- Creating an installer using Wix v3.0, Votive, and Visual Studio 2005/2008 - Part 2, the GUI
Hope this step by step article has given te right direction and how to start working with Wix.All the experiment files are attached herewith.Thanks for reading.