giovedì 6 agosto 2015

Visual studio setup projects: how to use the same custom dialog box more than one time

Making a setup project using Visual Studio, 2005 version in my case, is fast and easy and it is my favorite tool for old projects. A customization of the installation workflow is easy using custom action and custom dialog box. The problem raises when you need 2 or more dialog box of the same type: dialog box with options, in example. If you don't want to code your own dialog box and your own setup project, you can easily bypass such limitation with a little tip that I'm going to show.
A "Dialog box" derives from a template stored inside the main Visual Studio installation folder, usually
%ROOT%:\%PROGRAM FILES%\Microsoft Visual Studio 8\Common7\Tools\Deployment\VsdDialogs
. This folder includes several subfolders, one generic and one for each of the supported languages. In example the subfolder called 1033 stores the templates for the English language. The goal is to find the template we need to use more then one time. In this example I'm going to modify the "2 options dialog" where its templates is called "VsdCustom2ButtonDlg.wid". Make a copy of this file calling it "VsdCustom2ButtonDlg_2.wid" and open it with ORCA. Because Visual studio check the presence of equal templates when you build a setup project, you have to keep the characteristics of the dialog, to have 2 option buttons in our example, renaming all the occurrences of the previous name. Open the file in ORCA and select the table Module Dialog. Change the name from Custom2Buttons to Custom2Buttons_2. Now iterate for each table and when you find the old name Custom2Buttons, change it with the new one. You have to generate also a new GUID for the field ModuleId of the table Module signature At the end, you can save it. Now your duplicated "2 options dialog" is ready to use and you can choose it in the "Add Dialog" menu of the "User Interface" sction of your setup project.
I suggest to make the first copy of the dialog in the subfolder 0 that it is the generic one and to copy it for each of languages supported, in example 1033, 1045 etc. etc. The only field that you have to change when you copy your wid file from the subfolder  0 to another one is the field Language of the table Module Signature that it has to be changed according to the specific language. So, if you are porting your new dialog template from the default folder 0 to the English folder 1033, Language field has to be 1033.
That's all!