tags:

views:

752

answers:

2

I have a WiX installer project that utilises a custom dialog box to ask for parameters to update a web.config file and run a database script on install. Everything works correctly and the application is installed and runs correctly.

However, the custom dialog box is also displayed when I uninstall the software and it certainly doesn't need to be (as I'm not updating a web.config file).

Is there a way to suppress the custom dialog when the application is being uninstalled?

(I should also remove the sql procs I install, at uninstall time but that is outside of this issue).

+2  A: 

The solution to your question is to condition the custom action with the condition (Not REMOVE="ALL"). This will make the action run on fresh install and maintenance install, but not on uninstall. If you don't need to run on maintenance install, but only on a fresh install you can set the condition to be: (Not Installed AND Not(REMOVE="ALL")). Full list of MSI properties and brief descriptions here: http://msdn.microsoft.com/en-us/library/aa370905%28VS.85%29.aspx.

The sequencing and custom action logic in MSI files is VERY complicated. It really pays off to avoid custom actions whenever you can.

There is more - all MSI files have built-in support for silent installation. This means that the entire GUI sequence can be skipped, and the MSI file installed without user interaction. This is a crucial feature for corporate deployment via SMS / SCCM or other deployment mechanisms. Showing a custom dialog box when the setup is run in silent mode is a violation of this basic MSI feature. You can work around this by properly conditioning the display of the dialog based on the property UILevel: http://msdn.microsoft.com/en-us/library/aa372096%28VS.85%29.aspx. Just to keep things interesting and confusing Microsoft has defined 4 levels of GUI during an installation ranging from completely silent, through various options such as progress bar only etc... See the link for details.

I could add a lot of details here about MSI sequences, conditions, custom actions and similar, but it wouldn't answer your question. Please add any follow-up questions.

Glytzhkof
I'm new to Wix. I'm at a loss to follow what you mean. I'm not installing a custom action, I'm defining a UI element to display a custom screen to get data to update web.config. I then use properties (eg [DATABASENAME]) to update connectionString in web.config, using util:XmlFile ... command from WiXUtilExtension.
rob_g
<InstallUISequence> <Show Dialog="InstallDlg" After="WelcomeDlg" Overridable="yes" /></InstallUISequence>Is what I am doing to display my custom UI element.
rob_g
<InstallUISequence> <Show Dialog="InstallDlg" After="WelcomeDlg" Overridable="yes"><![CDATA[NOT Installed AND NOT REMOVE~="ALL"]]></Show></InstallUISequence>
Glytzhkof
The main point I tried to make with regards to silent installation, is that if the GUI isn't shown, the value won't be set unless you pass the value of DATABASENAME into the msiexec.exe command line:msiexec.exe /i MyPackage.msi DATABASENAME="mydbserver" /qn
Glytzhkof
A: 

Wix snippet to show the creation of a custom action and its insertion into the InstallExecuteSequence:

<!--Custom Action Sample Section-->
<Binary Id='VBScriptCustomAction.vbs' SourceFile='VBScriptCustomAction.vbs'/>
<CustomAction Id='test' BinaryKey='VBScriptCustomAction.vbs' VBScriptCall='Hello' Return='ignore'/>

<InstallExecuteSequence>
  <Custom Action="test" Sequence='4111'><![CDATA[NOT REMOVE~="ALL"]]></Custom>
</InstallExecuteSequence>
<!-- End of Custom Action Sample Section-->
Glytzhkof