从命令行传递的 WiX 条件属性不起作用? [英] WiX condition properties passed from command line don't work?

查看:18
本文介绍了从命令行传递的 WiX 条件属性不起作用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

当前快捷方式代码:

<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 的建议并添加以下内容:

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"/>

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

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

尝试将值放在引号中,但仍然不行.此处未显示,但我通过执行 ALLUSERS="" 或 ALLUSERS="2" 成功操纵 ALLUSERS 属性以执行每个用户或每台机器的注册表所以应该可以传递属性,但我不确定是什么我做错了.

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.

推荐答案

这里有两个问题,两件事:

Two things since there are two questions here:

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

我有一个 关于如何创建快捷方式和通过验证的博文.

  1. 您使用的属性需要标记为安全才能从安装 UI 过程传递到服务器端.要做到这一点,只需这样做

  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"/>

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

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

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.

这篇关于从命令行传递的 WiX 条件属性不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆