petetherock
petetherock

Reputation: 1

Wix Component UPGRADINGPRODUCTCODE condition not working

I do not want SQL scripts to be executed when automatic uninstall happens because a major upgrade removes existing products.

The problem is that I have the database user name and password passed as a command line parameter, so when it does the upgrade and automatically runs the uninstall it tries to execute the SQL scripts, but there is not database username or password, so the upgrade then fails. You can see in SQL Profiler that the username is set to '' (blank).

My component code is as follows:

<Component Id="SQL" Guid="AF267662-23A0-4b46-B490-C11465BE9858" KeyPath="yes" >
<Condition>NOT UPGRADINGPRODUCTCODE AND NOT REMOVE="ALL"</Condition>            
<!--UNINSTALL-->
<sql:SqlScript Id="Uninstall.SQLScript" ExecuteOnInstall="no" ExecuteOnUninstall="yes" BinaryKey="SQLScript.Uninstall" User="SQLUser" SqlDb="SqlDatabase" Sequence="1"/>

<!--INSTALL-->
<sql:SqlScript Id="SQLScript2" ExecuteOnInstall="yes" ExecuteOnUninstall="no" BinaryKey="SQLScript.Create.DBObjects" User="SQLUser" SqlDb="SqlDatabase" Sequence="3"/>
</Component>

Upvotes: 0

Views: 2028

Answers (1)

PhilDW
PhilDW

Reputation: 20780

The condition should be on the custom action, not on the component. This has a good example:

Wix: Run custom action based on condition

Same here: How can I perform a custom action in WiX that only executes on install or uninstall?

When you put a condition on a component you're making it transitive, meaning the install state of the component will vary during install and repair based on the value of the property. That's not really what you need, that's why you should condition the CA and not the component.

Upvotes: 1

Related Questions