How to register a COM dll on condition based in WI

2019-09-17 17:15发布

问题:

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.?

回答1:

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.