WIX Custom Actions sequence - wix

I have defined a few Custom Actions in my WIX setup, and these actions call third party EXE's that our application depends on. The user decides to install or ignore these 3rd party applications from the feature tree. My CustomAction and binary tags look like this:
<CustomAction Id='NL220_Action' BinaryKey='NL220EXE' Return='asyncWait' />
<Binary Id="NICEXE" SourceFile="..\NL220.exe" />
<CustomAction Id='NIC_Action' BinaryKey='NICEXE' Return='asyncWait' />
<Binary Id="NICEXE" SourceFile="..\NIC.exe" />
Furthermore, my InstallExecuteSequence tag looks like this:
<InstallExecuteSequence>
<Custom Action="NL220_Action" After="InstallFinalize"><![CDATA[(&Optional_NL220=3)]]></Custom>
<Custom Action="NIC_Action" After="NL220_Action"><![CDATA[(&Optional_NIC=3)]]></Custom>
</InstallExecuteSequence>
Everything works fine: the user can select which 3rd party installer packages to run, and these are then run when the installer finishes. The problem is that if the user selects both 3rd party installers, they are run at the same time, thus ignoring the After="NL220_Action" attribute of the second custom action. Any ideas why this is?

Per Custom Action Return Processing Options, the wait of asyncWait occurs at the end of a sequence. Use of this value means that you need the action to succeed, but you don't care exactly when it succeeds. If it waited for the custom action to finish before continuing onward, it would be synchronous. If you need to wait for the first to complete before running the second, then either you need to make the first action synchronous, or possibly combine both actions into a single asynchronous action which itself runs the two sub-actions in ordered sequence.

Related

Wix - schedule custom action between StopServices and StartServices

I would like to add a custom action in my Wix installer that runs between the StopServices and the StartServices. So that the service is down when the custom action is running. If I do the following the action runs before the StartServices, but also before the StopServices.
<Custom Action="IisRewriteRules" After="StopServices" Before="StartServices"> NOT REMOVE~="ALL" </Custom>
It seems that I can't add both a Before and After tag, that gives following error:
Error CNDL0035: The Custom/#After attribute cannot be specified when attribute Before is present. (20)
Is there some way I can achieve this? As a backup I guess I could stop the service in my custom action and restart it again at the end of the custom action, but I would prefer to not have to do that.
Looking online I couldn't really find anything. Is there maybe a way to schedule the ServiceControl?
I found in the Wix Docs that you can add a Sequence tag instead of Before or After. You can pass this an integer value and schedule it between the default actions. Following page shows the default actions and their corresponding Sequence value: Suggested InstallExecuteSequence

Read Checkbox value in a deferred custom action

I am working on an installer where I have to add a dialog for the user to make some application configuration choices. The dialog is shown before the installment procedure and the the configuration choices can only be applied after the installment when the required file are installed. The required file is some kind of configuration file which must be adapted based on the chosen configuration.
The sequence is as follows:
Start up the installer
Choose installation folder
Choose desired configuration
Install the application
Change the configuration based on the chosen desired configuration
The configuration dialog will have 2 components: one checkbox and one dropdownlist. Currently I am struggling with the checkbox and reading it's value in a deferred Custom Action. This Custom Action is executed after the installation is finished.
So far, this is the code I have:
<Dialog Id="TempDlgId" ...>
<Control Id="MyCheckBoxId" Type="CheckBox" ... CheckBoxValue="0" Property="MyCheckBoxValue" Text="Sampe Text"/>
</Dialog>
This is the dialog for the user to choose the configuration.
<Custom Action="MyCustomAction.SetProperties" After="InstallFiles">NOT Installed</Custom>
<Custom Action="MyCustomAction" After="MyCustomAction.SetProperties">NOT Installed</Custom>
I applied the sequencing for my custom actions.
<CustomAction Id="MyCustomAction.SetProperties"
Return="check"
Execute="immediate"
Property="MyCustomAction"
Value="InstallLocation=[DEFAULTWORKINGDIRECTORY];MyCheckBoxValue=[MyCheckBoxValue]"/>
<CustomAction Id="MyCustomAction"
Return="check"
Execute="deferred"
BinaryKey="MyCustomAction.CA.dll"
Impersonate="yes"
DllEntry="MyCustomAction"
HideTarget="no"/>
Here is my definition of the custom actions.
[STAThread]
[CustomAction]
public static ActionResult MyCustomAction(Session session)
{
Debugger.Launch();
var installLocation = session.CustomActionData["InstallLocation"];
var hasModule = session.CustomActionData["MyCheckBoxValue"];
return ActionResult.Success;
}
This code has to change the configuration of the installed application and currently I am struggling with getting the checkbox value. It doesn't matter if the checkbox is checked or not, MyCheckBoxValue is always empty. Is it possible to get the value of a checkbox in a deferred action? If it is possible, what do I have to do to get the checkbox value?
Since I am new to working on installers, I was not familiar with the fact that upper case actually has a functionality for creating installers with WiX. As soon as I wrote MyCheckBoxValue completely in uppercases, it became a public property and I managed to get it's value in the deferred Custom Action.

How to register a COM dll on condition based in WIX Installer

Am running a Command to register a dll using the below code in WIX installer
<CustomAction Id='comReg' Directory='INSTALLLOCATION' Impersonate='no' Execute='deferred'
ExeCommand='"[NETFRAMEWORK40CLIENTINSTALLROOTDIR]regasm.exe" "[INSTALLLOCATION]myProduct.dll" /codebase' Return='check' />
<CustomAction Id='comUnreg' Directory='INSTALLLOCATION' Impersonate='no' Execute='deferred' ExeCommand='"[NETFRAMEWORK40CLIENTINSTALLROOTDIR]regasm.exe" /u "[INSTALLLOCATION]myProduct.dll" /codebase' Return='check' />
for registry entry and its working fine and my setup is also working cool. But now i need to register this in condition based (ie) in my installer i have given a checkbox ,if its checked then need to register the dll else no need to register.
I have used conditions for other uses by using <Condition>INSTALLADDIN</Condition> but its working only inside a <Component> </Component> but my command was inside <Product></Product> , how to set the condition for the above mentioned.??
and if i used as below
<Condition Message='EA-Addin not installed'>INSTALLADDIN</Condition>
above that code it shows that message and getting terminated.If i didnt set the message property it shows an error that message is a required property.How to overcome this problem.?
You need a condition on the custom action in your situation, I assume you've added it to the execute sequence somewhere but there's no condition on it.
Having said that, that's not really the way to do registration. Use Heat to extract it into a component with the Dll. You'd probably need need two components, one with the file+registration and one with just the file, make them mutually exclusive, and use the remember property pattern on the property. Condition the appropriate component on the condition.
There are conditions everywhere - it looks like you are confusing launch conditions (Condition Message...) with component conditions and custom action conditions.

wix SetProperty After attribute won't take custom action Id

After reading the page on SetProperty and looking at as many examples as I could find here and elsewhere, I'm still not able to get my SetProperty to work with After or Before set to one of my custom action IDs. The documentation seems very simple and straight forward on the subject (hah!), but I'm getting "Found an ActionRow with a non-existent After action: MyWonderfulCA" instead of happiness (which really is what I'm after : ) Here's a representation of what my code looks like:
<CustomAction Id="MyWonderfulCA" BinaryKey="MyWonderful.dll" DllEntry="MyWonderfulCA" Execute="immediate" />
<InstallExecuteSequence>
<Custom Action="MyWonderfulCA" After="LaunchConditions" />
</InstallExecuteSequence>
<Property Id="SOMEPROPERTY" />
<SetProperty Id="SOMEPROPERTY" After="MyWonderfulCA" Value="[SOMEOTHERPROPERTY]the\yellow\brick\road">WEAREHUNKYDORY</SetProperty>
So anyway, save me SOF wix pros, you're my only hope...
I'm not sure, but the following thing looks suspicious.
The <SetProperty> (link) element has Sequence attribute, which is optional. If you don't specify it (like in the sample you posted), it gets the value of both, which means the custom action of type 51 (which is what SetProperty translates to) is scheduled into both InstallUISequence and InstallExecuteSequence.
However, as far as I can see, you only schedule MyWonderfulCA into the InstallExecuteSequence. Hence, it makes me think that when WiX tries to schedule SetProperty into the InstallUISequence, it can't find the custom action specified in After attribute and fails.
Check this out by either specifying the Sequence='execute' explicitly, or by scheduling your wonderful CA into both sequence. If it is the case, then just choose the most appropriate way out of these two.

How can I disable a Wix component when a Feature is selected?

It's easy in Wix to enable a component when a feature is selected. I want to do the opposite of that, where the component will be installed unless a given feature is selected. The reason is that the component performs a configuration change that is not required if the given feature is chosen.
Failed Experiments:
I've tried using conditions in the component:
<Component ...>
<Condition>&Feature = 3</Condition>
...
</Component>
That doesn't work, because apparently the feature states are not calculated at the point where the component conditions are evaluated.
I've also tried using a custom action set to run before CostFinalize in order to set a property that can be tested in the Component condition. This also didn't work:
<Custom Action="Transfer_Feature_State" Before="CostFinalize" />
<Custom Action="Transfer_Feature_State_Property" Before="MtpWeb_Features_LabManager" />
<Custom Action="Transfer_Feature_State_Feature" Before="MtpWeb_Features_LabManager" />
When the custom action ran, the feature state was still set as -1, so the feature states have not been calculated before CostFinalize.
Is there any way to disable a component based on feature selection?
Components are organized into features. This means that by default all components in a feature are installed. If you don't want a feature to install a component, you can make sure that the component is not included in that feature.
What you really want is mutually exclusive features. Basically a feature which contains the component can be installed only if the other feature is not installed and the other way around.
This is not supported by Windows Installer, so it can be done only with a custom action. Basically, when the given feature is selected you can use MsiSetFeatureState function to make sure that the other feature which contains your component is not installed.