Making a custom setup dialog using WiX 3.0

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.

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

1

AND

NOT Installed

-----

                  1                           1                           1        

       
       
       
       
       

       
       
       
       

     

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 -line with this:

      <![CDATA[WIXUI_INSTALLDIR_VALID="1"]]>

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:

Simply replace this with and you're clear :) 

Note: in my iDTADlg I stored some values in properties. These properties were also defined in the Product.wxs file:
   
   

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:

This article is part of the GWB Archives. Original Author: Jan Schepens

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.