Recently I started diving into WiX (Windows Installer XML) as a toolset for a setup project I needed to create. And it didn't take much time to discover that WiX provides some nice out of the box dialogs without having to do much work.
That is, if you only need the basic configurations, such as a folder browse dialog and a license agreement.
However, my project required just that little extra dialog, to provide the location of a SQL database. Basically, what I needed was two textboxes, one to input the server name, and one to input the SQL instance name.
The bad news first: there is not much documentation available (I feel) on how to create some custom dialog stuff.
The good news: it doesn't take much work to do so :) here's how.
You may or may not know that WiX provides some basic layout schema's, from the WiXUI assembly. These are WixUI_Mondo, WixUI_FeatureTree, WixUI_InstallDir, and WixUI_Minimal. In my project, I used WixUI_InstallDir, just for the reason of the need to be able to select a folder to install to.<br /><br />
So what you need to do first is download the source code of WiX. It's an open source project located on SourceForge
Once that's done, locate the file WixUI_InstallDir.wxs in the source folder, add it to your own WiX setup project, and name it MyWixUI_InstallDir (basically, you can choose whatever name you want). Open the MyWixUI_InstallDir file in code window of Visual Studio.
Now, to get what I wanted, I simply added the following code between
<Publish Dialog="InstallDirDlg" Control="ChangeFolder" Event="SpawnDialog" Value="BrowseDlg" Order="2">1</Publish>
AND
<publish dialog="VerifyReadyDlg" control="Back" event="NewDialog" value="InstallDirDlg" order="1">NOT Installed</publish>
-----
<dialog id="iDTADlg" width="370" height="270" title="Localisation of the BizTalk Tracking database">
<control id="Next" type="PushButton" x="236" y="243" width="56" height="17" default="yes" text="Next">
<publish event="NewDialog" value="VerifyReadyDlg">1</publish>
</control>
<control id="Back" type="PushButton" x="180" y="243" width="56" height="17" text="Back">
<publish event="NewDialog" value="iSQLDlg">1</publish>
</control>
<control id="Cancel" type="PushButton" x="304" y="243" width="56" height="17" cancel="yes" text="Cancel">
<publish event="SpawnDialog" value="CancelDlg">1</publish>
</control>
<control id="Description" type="Text" x="25" y="23" width="280" height="15" transparent="yes" noprefix="yes" text="Enter SQL Server and Instance to deploy DTA tables to." />
<control id="Title" type="Text" x="15" y="6" width="200" height="15" transparent="yes" noprefix="yes" text="{\WixUI_Font_Title}Localisation of the DTA database" />
<control id="BannerBitmap" type="Bitmap" x="0" y="0" width="370" height="44" tabskip="no" text="!(loc.InstallDirDlgBannerBitmap)" />
<control id="BannerLine" type="Line" x="0" y="44" width="370" height="0" />
<control id="BottomLine" type="Line" x="0" y="234" width="370" height="0" />
<control id="DBServer" type="Text" x="20" y="60" width="290" height="13" noprefix="yes" text="Name of the SQL Server to deploy the DTA script" />
<control id="DBSText" type="Edit" x="20" y="72" width="290" height="18" property="DTAServer" />
<control id="DBInstance" type="Text" x="20" y="93" width="290" height="13" noprefix="yes" text="Name of the SQL instance to deploy the DTA script" />
<control id="DBIText" type="Edit" x="20" y="105" width="290" height="18" property="DTAInstance" />
</dialog>
As you can see, I named this new dialog iDTADlg.
Now to force this dialog to be shown after you chose the install location, you need to find the Publish InstallDirDlg tags and replace the <control event="NewDialog">-line with this:
<publish dialog="InstallDirDlg" control="Next" event="NewDialog" value="iDTADlg" order="4"><![CDATA[WIXUI_INSTALLDIR_VALID="1"]]></publish>
OK, so that's it for the dialog itself. Now, you normally have a file in your project called Product.wxs. If you want to make use of the WixUI features, you should already have something like this in your file: <uiref id="WixUI_InstallDir" />
Simply replace this with <uiref id="MyWixUI_InstallDir" /> and you're clear :)
Note: in my iDTADlg I stored some values in properties. These properties were also defined in the Product.wxs file:
<property id="WIXUI_DTAServer" value="DTAServer"></property>
<property id="WIXUI_DTAInstance" value="DTAInstance"></property>
So that's it.
So when I run the setup, I get this little basic dialog asking me for a SQL server and an instance:
