top of page
index-1-1.jpg

Automating WIX Installer using CCNET

This is the last article of the series Continuous Integration in .NET using Cruise Control.net. In the last article we had discussed that how we can use NUnit with ccnet to run our test cases. In this article we are going to discuss that how we can automate the WIX installers. For this you should have a wix installed in your system. We will continue with our trade simulator example.


Add the new installer project in the solution. For making installer, adding components is the major part. We will use heat command which comes with wix to generate the component file. For this yours wix toolset bin folder should be added in the environment variable folder. Here are the wix heat commands to be used

heat dir "D:ReposcruisecontrolAurora_UIAurora_UIbinRelease" -dr AuroraUI -cg AuroraUI -gg -g1 -sf -srd -sreg -var "var.UI" -out "D:ReposcruisecontrolAurora_UITradeSimulatorUI.wxs"

In this heat is the command, remaining are its arguments, lets discuss them one by one:

dir: is used for the directory to harvest, off course release folder will contain all the files required for the application to run.

-dr: is used to refer the directory in the WIX file.

-gg: will generate new GUID's for each component

-g1: will be used to generate GUID's without curly brackets, it used with -gg

-sreg: it is used to suppress registry harvesting

-cg: is used to name the component group.

var.UI: It’s the wix environment variable, it will contain the same path as the dir, you just need to add once in the project.

-out: It tells us the path and filename, where to generate the .wxs(the component) file.


Now run these commands in the command line to have these files generated. Now add them in the solution and refer these components files in the section.


Now add the environment variables in the properties:


Now we have build the installer. Now the next part is automating it. Now right click on the solution in the configuration manager uncheck the installer project so that it should not get build with the solution file because we have to make the installer from freshly compiled libraries so when the solution is build completely we will than compile our installer project. So here is new NAnt build script.

<?xml version="1.0" encoding="utf-8"?>
<project name="Trade Simulator" default="TestCases">
<target name="build.Project">
<delete dir="C:/results" />
<exec program="C:WindowsMicrosoft.NETFrameworkv4.0.30319MSBuild.exe">
<arg value="D:ReposcruisecontrolAurora_UIAurora_UI.sln" />
<arg value="/t:Rebuild" />
<arg value="/p:Configuration=Release" />
</exec>
</target>
<target name="build.Installer" depends="build.Project">
<exec program="D:ReposcruisecontrolAurora_UITradeSimulatorWIX_Heat.bat" />
<exec program="C:WindowsMicrosoft.NETFrameworkv4.0.30319MSBuild.exe">
<arg value="D:ReposcruisecontrolAurora_UITradeSimulatorTradeSimulator.wixproj" />
<arg value="/t:Rebuild" />
<arg value="/p:Configuration=Release" />
</exec>
</target>
<target name="TestCases" depends="build.Installer">
<nunit2 haltonfailure="False" failonerror="True">
<formatter type="Xml" usefile="true" extension=".xml" outputdir="C:/results" />
<test>
<assemblies>
<includesfile name="UnitTestAssemblies.txt" />
</assemblies>
</test>
</nunit2>
</target>
</project>

In this script i have added the new target to build the installer after the solution compiles successfully. The first exec task will run a dos bat file to generate components from release folders. Than we build the installer project. The installer i have created is simple one, and this article is not about creating installer, its just ablut how you can automate your wix installer project.


Previous articles link:

bottom of page