Wix 布尔属性值不起作用
我有以下属性:
<Property Id="UPDATEDB">1</Property>
UI 中绑定到该属性的复选框:
<Control Id="updateDatabase" Type="CheckBox" CheckBoxValue="1" Height="15" Width="95" X="20" Y="74" Text="Update Database" Property="UPDATEDB" />
以及一个自定义操作,它根据此属性的值执行某些操作
<CustomAction Id="RunDbMigration" Directory="INSTALLDIR" Return="check"
ExeCommand='[DBMIGRATIONDIR]\DbMigration.exe' />
<InstallExecuteSequence>
<Custom Action="RunDbMigration" After="InstallFinalize">UPDATEDB=1 AND NOT Installed</Custom>
</InstallExecuteSequence>
如果我尝试从命令行传递 UPDATEDB 的值 0:
msiexec /i "Setup.msi" /l* UPDATEDB=0
或
msiexec /i "Setup.msi" /l* UPDATEDB="0"
值无论如何,该复选框都会被选中。也就是说,传入的 0 似乎受到尊重,并且 RunDbMigration 操作未运行...
这里发生了什么?为什么这是如此复杂的科学?
I have the following property:
<Property Id="UPDATEDB">1</Property>
A checkbox in the UI bound to that property:
<Control Id="updateDatabase" Type="CheckBox" CheckBoxValue="1" Height="15" Width="95" X="20" Y="74" Text="Update Database" Property="UPDATEDB" />
And a Custom Action which does something based on the value of this property
<CustomAction Id="RunDbMigration" Directory="INSTALLDIR" Return="check"
ExeCommand='[DBMIGRATIONDIR]\DbMigration.exe' />
<InstallExecuteSequence>
<Custom Action="RunDbMigration" After="InstallFinalize">UPDATEDB=1 AND NOT Installed</Custom>
</InstallExecuteSequence>
If I try to pass a value of 0 for UPDATEDB from the command line:
msiexec /i "Setup.msi" /l* UPDATEDB=0
or
msiexec /i "Setup.msi" /l* UPDATEDB="0"
the value of the checkbox is checked anyway. That said, the 0 passed in seems to be respected and the RunDbMigration action is not run...
What's going on here? Why is this such rocket science?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如其他人提到的,复选框不是 1/0 意义上的布尔值,而是 null/not-null 意义上的布尔值。
要从命令行取消设置 - 您可能需要使用类似的内容
,您的条件可能在执行自定义操作之前专门查找 1 的值,这就是您的 CA 未运行的原因。
As others have mentioned, Checkboxes are not boolean in a 1/0 sense, they're boolean in a null/not-null sense.
To unset from the command line - you would want to use something like
Chances are that your condition is looking specifically for the value of 1 before executing your custom action, which is why your CA isn't being run.
安装程序属性要么设置为一个值,要么不设置。在内部,该值只是一个字符串,因此“0”、“1”、“true”和“false”是相同的。
当复选框控件的属性设置为某个值(无关紧要)时,复选框控件将被选中;而当其属性为空时,复选框控件将被取消选中。
此命令行设置属性并选中复选框:
此命令行不设置属性,因此未选中复选框:
Installer properties are either set to a value or they are not set. Internally the value is just a string, so "0", "1", "true" and "false" are the same.
A checkbox control is checked when its property is set to a value (doesn't matter what) and unchecked when its property is empty.
This command line sets the property and checks the checkbox:
This command line doesn't set the property, so the checkbox is not checked:
问题是 CheckBoxValue="1"。您可以在这里找到问题的解决方案:https ://wix-users.narkive.com/HOW67H18/how-to-conditionally-check-uncheck-a-checkbox
The problem is the CheckBoxValue="1". You find the solution for your question here: https://wix-users.narkive.com/HOW67H18/how-to-conditionally-check-uncheck-a-checkbox