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

查看:72
本文介绍了从命令行传递的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和命令行。我要传递的命令行是:

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 Installer将广告的Shorcut指向组件的KeyPath。因此,如果要选择性安装广告,则不能使用广告的Shorcut。

我有一个有关如何创建的博客文章

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


  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

<属性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天全站免登陆