从命令行传递的 WiX 条件属性不起作用?

发布于 2024-07-20 05:58:26 字数 1710 浏览 5 评论 0原文

我有一个属性用于确定是否安装需要通过命令行参数传递的快捷方式。 当我在 wxs 文件中设置属性时,这些条件似乎有效,但通过命令行设置它们时,它们似乎被忽略。 从日志中我看到它们正在被设置:

MSI (s) (24:C8) [11:01:32:234]: PROPERTY CHANGE: Modifying INSTALLSTARTUPSHORTCUT property. Its current value is '0'. Its new value: '1'.
MSI (s) (24:C8) [11:01:32:234]: PROPERTY CHANGE: Modifying INSTALLSTARTMENUSHORTCUT property. Its current value is '0'. Its new value: '1'.
MSI (s) (24:C8) [11:01:32:234]: PROPERTY CHANGE: Modifying INSTALLDESKTOPSHORTCUT property. Its current value is '0'. Its new value: '1'.

但是,它们没有安装快捷方式。

此外,似乎由于它们需要在自己的组件中才能设置条件,因此它们不能再成为广告的快捷方式。 如何获得有条件安装的广告快捷方式?

当前快捷方式代码:

<Property Id="INSTALLSTARTMENUSHORTCUT" Value="0"/>
...
<Component Id="StartMenuShortcut" Guid="MY-GUID">
  <Condition>INSTALLSTARTMENUSHORTCUT</Condition>
  <Shortcut Id="StartMenuServerShortcut"
    Directory="ProgramMenuDir"
    Name="Application Name" WorkingDirectory="INSTALLDIR" Advertise="no"
    Target="[!FileEXE]"
    Icon="Icon.ico" />
</Component>

并对其他快捷方式重复

编辑:

尝试 Sacha 建议的内容并添加以下内容:

<Property Id="INSTALLSTARTUPSHORTCUT" Value="0" Secure="yes"/>
<Property Id="INSTALLDESKTOPSHORTCUT" Value="0" Secure="yes"/>
<Property Id="INSTALLSTARTMENUSHORTCUT" Value="0" Secure="yes"/>

现在它会安装所有快捷方式,即使它们在 xml 和命令行中都设置为 0。 我传递的命令行是:

msiexec /i MySetup.msi INSTALLSTARTUPSHORTCUT=0 INSTALLDESKTOPSHORTCUT=0 INSTALLSTARTMENUSHORTCUT=0 /l*v inst.log /qb

尝试将值放在引号中,但仍然不行。 此处未显示,但我成功地通过执行 ALLUSERS="" 或 ALLUSERS="2" 操作 ALLUSERS 属性来执行每用户或每台计算机的注册表,因此传入属性应该是可能的,但我不确定什么我做错了。

I have a property for whether to install shortcuts that need to be passed via command line arguments. The conditions seem to work when I set the properties within the wxs file, but they seem to be ignored when setting them through the command line. From the log I see that they are being set:

MSI (s) (24:C8) [11:01:32:234]: PROPERTY CHANGE: Modifying INSTALLSTARTUPSHORTCUT property. Its current value is '0'. Its new value: '1'.
MSI (s) (24:C8) [11:01:32:234]: PROPERTY CHANGE: Modifying INSTALLSTARTMENUSHORTCUT property. Its current value is '0'. Its new value: '1'.
MSI (s) (24:C8) [11:01:32:234]: PROPERTY CHANGE: Modifying INSTALLDESKTOPSHORTCUT property. Its current value is '0'. Its new value: '1'.

However, they the shortcuts aren't being installed.

Also, it seems like since they need to be in their own component to be able to set conditions on them, they can no longer be advertised shortcuts. How would you get conditionally installed advertised shortcuts?

Current shortcut code:

<Property Id="INSTALLSTARTMENUSHORTCUT" Value="0"/>
...
<Component Id="StartMenuShortcut" Guid="MY-GUID">
  <Condition>INSTALLSTARTMENUSHORTCUT</Condition>
  <Shortcut Id="StartMenuServerShortcut"
    Directory="ProgramMenuDir"
    Name="Application Name" WorkingDirectory="INSTALLDIR" Advertise="no"
    Target="[!FileEXE]"
    Icon="Icon.ico" />
</Component>

And repeated for other shortcuts

Edit:

Trying what Sacha suggested and adding the following:

<Property Id="INSTALLSTARTUPSHORTCUT" Value="0" Secure="yes"/>
<Property Id="INSTALLDESKTOPSHORTCUT" Value="0" Secure="yes"/>
<Property Id="INSTALLSTARTMENUSHORTCUT" Value="0" Secure="yes"/>

Now it installs all the shortcuts even though they're set to 0 both in the xml and on the command line. The command line I'm passing is:

msiexec /i MySetup.msi INSTALLSTARTUPSHORTCUT=0 INSTALLDESKTOPSHORTCUT=0 INSTALLSTARTMENUSHORTCUT=0 /l*v inst.log /qb

tried putting the values in quotes and still no go. Not shown here, but I was successful in manipulating the ALLUSERS property to do per-user or per-machine registries by doing ALLUSERS="" or ALLUSERS="2" So passing in properties should be possible, but I'm not sure what I'm doing wrong.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

迷荒 2024-07-27 05:58:26

由于这里有两个问题,所以有两件事:

  1. 广告的快捷方式必须位于安装它们指向的文件的同一组件中。 这是必需的,因为 Windows Installer 将公告的快捷方式指向组件的 KeyPath。 因此,如果您希望选择性安装广告快捷方式,则不能使用它们。

我有一个 有关如何创建快捷方式并通过验证的博客文章

  1. 您正在使用的属性需要标记为安全才能从安装 UI 进程传递到服务器端。 为此,只需执行

请注意,我没有添加 Value 属性。 如果您指定一个值,即使它是 0,那么您的 INSTALLSTARTMENUSHORCUT 将计算为 TRUE。 空白/未定义的属性为 FALSE,任何其他值均为 TRUE。

Two things since there are two questions here:

  1. Advertised Shortcuts must be in the same Component that installs the File they point at. That is requried because the Windows Installer points an advertised Shorcut at the KeyPath of the Component. So, you can't use advertised Shorcuts if you want them to be optionally installed.

I have a blog post about how to create a shorcut and pass validation.

  1. The Properties you are using need to be marked secure to pass from the install UI process to the server-side. To do that just do

    <Property Id="INSTALLSTARTMENUSHORTCUT" Secure="yes"/>

Notice that I did not add a Value attribute. If you specify a Value, even if it is 0, then your INSTALLSTARTMENUSHORCUT will evaluate to TRUE. A blank/non-defined Property is FALSE, any other value is TRUE.

我的鱼塘能养鲲 2024-07-27 05:58:26

您是否尝试过将属性标记为安全?

<Property Id="INSTALLSTARTMENUSHORTCUT" Value="0" Secure="Yes" />

查看 快捷表 的文档不要认为您可以获得有条件广告的快捷方式。 我们通过安装广告开始菜单快捷方式和常规桌面快捷方式来解决这个问题。

Have you tried marking the properties as secure?

<Property Id="INSTALLSTARTMENUSHORTCUT" Value="0" Secure="Yes" />

Looking at the documentation for the Shortcut Table I don't think you can get conditionally advertised shortcuts. We get around this by installing an Advertised start menu shortcut, and a regular desktop shortcut.

萧瑟寒风 2024-07-27 05:58:26

如果 IIRC Advertise 必须下注设置为“是”,

您已经在 MindCapers 此处看到了这个示例,我有在我创建注册表项之前,快捷方式遇到了麻烦。

If IIRC Advertise has to bet set at Yes

You have seen this example from MindCapers here, I had trouble with the Shorcuts until I created the registry entry.

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