Wix 布尔属性值不起作用

发布于 2024-12-07 18:22:35 字数 934 浏览 2 评论 0原文

我有以下属性:

<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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

云醉月微眠 2024-12-14 18:22:35

正如其他人提到的,复选框不是 1/0 意义上的布尔值,而是 null/not-null 意义上的布尔值。

要从命令行取消设置 - 您可能需要使用类似的内容

msiexec /i "Setup.msi" /l* UPDATEDB=""

,您的条件可能在执行自定义操作之前专门查找 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

msiexec /i "Setup.msi" /l* UPDATEDB=""

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.

走野 2024-12-14 18:22:35

安装程序属性要么设置为一个值,要么不设置。在内部,该值只是一个字符串,因此“0”、“1”、“true”和“false”是相同的。

当复选框控件的属性设置为某个值(无关紧要)时,复选框控件将被选中;而当其属性为空时,复选框控件将被取消选中。

此命令行设置属性并选中复选框:

msiexec /i "Setup.msi" /l* UPDATEDB="0"

此命令行不设置属性,因此未选中复选框:

msiexec /i "Setup.msi" /l*

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:

msiexec /i "Setup.msi" /l* UPDATEDB="0"

This command line doesn't set the property, so the checkbox is not checked:

msiexec /i "Setup.msi" /l*
‖放下 2024-12-14 18:22:35

问题是 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文