Wix Installer:在命令行执行MSIEXEC管理员安装时设置组件条件属性 [英] Wix Installer : Setting component condition property when doing a MSIEXEC admin install at command line

查看:132
本文介绍了Wix Installer:在命令行执行MSIEXEC管理员安装时设置组件条件属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的产品有三种类型/口味,但是只有一种用WiX编写的MSI。当我们构建安装程序时,我们通过定义的常量传递风味:

 调用MSBUILD.bat ..\MSIs\ CoreProduct\OurProduct.sln / p:DefineConstants = FLAVOUR =%_ Flavour% 

在Visual Studio中的构建->将预处理器变量定义为FLAVOUR = 50下进行设置。构建过程会传递50、200或LITE值。



在WiX代码中,我们的组件有很多条件,告诉它们要安装哪个文件。根据风味;例如

 <组件ID = = cmp7F45920B1AA100729BAE37FC846B3FC5 Guid = *> 
< File Id = fil238A776D9294E14671E012472F9F7196
KeyPath = yes
Source = $(var.MenusPath)\ClientListView 200.r5m
< Condition> $ (var.FLAVOUR)= 200< Condition>
< / Component>

<组件ID = = cmp8BFF42B232724DC4BA5B8F87994DEF21 Guid = *>
< File Id = fil808D6428D67248DDB8CA65DBC5978283
KeyPath = yes
Source = $(var.MenusPath)\ClientListView Lite.r5m
< Condition> $ (var.FLAVOUR)= LITE< / Condition>
< / Component>

因此,如果FLAVOR是LITE,则上面的示例将安装一个名为 ClientListView Lite.r5m的文件。如果FLAVOR是200,它将安装名为 ClientListView 200.r5m的文件。



这一切都按预期进行,并且已经完成了多年!!



但是,现在,我们有了产品的Web版本,我们需要一个zip文件来包含文件夹结构和每种风味将安装的文件。我发现您可以使用MSIEXEC和/ a参数在命令行上运行msi,然后将所有本应安装的内容重定向到文件夹&中。认为这正是我想要的...但是可惜它没有按预期工作。



它似乎正在执行的操作是运行MSI并提取文件到目标文件夹中,但是它忽略了这种风格,因此最终将 ClientListView Lite.r5m和 ClientListView 200.r5m文件都提取到该文件夹​​中;



在阅读MSIEXEC上的文档后,看来您可以传递Public属性的值,例如msiexec.exe / a C:\Example.msi MY_PROP = myValue-所以我认为这可能对我有帮助;因此,在我的WiX代码中,我添加了以下行:

 < Property Id ='PRODTYPE'Value = $(var.FLAVOUR ) /> 

,然后将组件条件更改为:

 < Component Id = cmp7F45920B1AA100729BAE37FC846B3FC5 Guid = *> 
< File Id = fil238A776D9294E14671E012472F9F7196
KeyPath = yes
Source = $(var.MenusPath)\ClientListView 200.r5m
< Condition>< ;![CDATA [PRODTYPE = 200]]< / Condition>
< / Component>

<组件ID = = cmp8BFF42B232724DC4BA5B8F87994DEF21 Guid = *>
< File Id = fil808D6428D67248DDB8CA65DBC5978283
KeyPath = yes
Source = $(var.MenusPath)\ClientListView Lite.r5m
< Condition>< ;![CDATA [PRODTYPE = LITE]]< / Condition>
< / Component>

尽管编译成功,但可以通过以下方式运行它:

  msiexec / a OurProduct.msi / qb PRODTYPE = 200 TARGETDIR = C:\InstalledFiles200 

仍会提取200& LITE调味品,我只想买200个。



所以,我是在尝试做一些不可能的事情...还​​是做错了-任何非常感谢您的帮助,因为可以在批处理文件中模仿该过程来创建我的zip;

干杯,



Chris。

= h2_lin>解决方案

msiexec命令行中的/ a开关不是通常意义上的安装。实际上,这只是将文件解压缩到某个位置。如果要实际安装,则必须使用/ i或双击MSI文件。这样一来,您可以在Programs& Features等条目中获得适当的完整安装。



通常通过将安装分为功能来选择安装什么,每个安装都包含一组包含所需功能的组件。在WiX UI中,您可以找到一个对话框来选择功能,而维护模式将使您返回并对其进行更改。在命令行安装中,您只需说/ i [msi文件] ADDLOCAL = Feature1,Feature2,依此类推。如果您真的想使用风味,则可以在内部将其转换为ADDLOCAL列表。


We have three types/flavours of our product, but only one MSI written in WiX. When we build the installer we pass in the flavour via a defined constant:

Call MSBUILD.bat ..\MSIs\CoreProduct\OurProduct.sln /p:DefineConstants="FLAVOUR=%_Flavour%"

and the constant is setup in Visual Studio, under Build -> Define preprocessor variables as FLAVOUR=50. The build process, passes in values 50, 200 or LITE as the flavour.

In the WiX code we have loads of conditions on our components that tell it which file to install based on the flavour; eg

      <Component Id="cmp7F45920B1AA100729BAE37FC846B3FC5" Guid="*">
    <File Id="fil238A776D9294E14671E012472F9F7196"
          KeyPath="yes"
          Source="$(var.MenusPath)\ClientListView 200.r5m"  
    <Condition>$(var.FLAVOUR)=200</Condition>
  </Component>

      <Component Id="cmp8BFF42B232724DC4BA5B8F87994DEF21" Guid="*">
    <File Id="fil808D6428D67248DDB8CA65DBC5978283" 
          KeyPath="yes" 
          Source="$(var.MenusPath)\ClientListView Lite.r5m"
    <Condition>$(var.FLAVOUR)=LITE</Condition>
  </Component>

So the example above will install a file called "ClientListView Lite.r5m" if the FLAVOUR is LITE or it will install a file called "ClientListView 200.r5m" if the FLAVOUR is 200.

This all works as expected and has done for years !!

But now, we have a web version of our product and we need a zip file to contain the folder structure and files that would be installed for each flavour. I discovered that you can run a msi at the command line using MSIEXEC and the /a argument which will then redirect everything that would have been installed into a folder & thought this is exactly what I want ... but alas it's not working as I'd expected.

What it seems to be doing is running the MSI and extracting the files into the target folder, but it is ignoring the flavour and so you end up with both the "ClientListView Lite.r5m" and "ClientListView 200.r5m" files been extracted into the folder; which is obviously not what I want.

Upon reading the docs on MSIEXEC, it seems that you can pass in the value for a Public property eg msiexec.exe /a "C:\Example.msi" MY_PROP="myValue" - so I thought this might help me; so in my WiX code I added the line:

    <Property Id='PRODTYPE' Value="$(var.FLAVOUR)"/>

and then altered my component conditions to be like:

  <Component Id="cmp7F45920B1AA100729BAE37FC846B3FC5" Guid="*">
    <File Id="fil238A776D9294E14671E012472F9F7196"
          KeyPath="yes"
          Source="$(var.MenusPath)\ClientListView 200.r5m"  
    <Condition><![CDATA[PRODTYPE=200]]></Condition>
  </Component>

  <Component Id="cmp8BFF42B232724DC4BA5B8F87994DEF21" Guid="*">
    <File Id="fil808D6428D67248DDB8CA65DBC5978283" 
          KeyPath="yes" 
          Source="$(var.MenusPath)\ClientListView Lite.r5m"
    <Condition><![CDATA[PRODTYPE=LITE]]></Condition>
  </Component>

but although that compiled ok, running it via:

msiexec /a OurProduct.msi /qb PRODTYPE=200 TARGETDIR="C:\InstalledFiles200"

still extracts both files for the 200 & LITE flavours, where I just wanted the one for 200.

So, am I trying to do something that is not possible ... or am I doing something wrong - any help would be gratefully appreciated, because the alternative of mimicking the process in a batch file to create my zip; will be horrendous !!

Cheers,

Chris.

解决方案

The /a switch in the msiexec command line is not an install in the usual sense. It is literally just an unpack of the files to a location. If you want an actual install you must use /i or just double-click the MSI file. That'll give you a proper full installation with an entry in Programs&Features and so on.

Choices of what to install are more normally handled by dividing the setup into features, each containing a set of components containing the required functionality. In the WiX UI you can get a dialog to choose the features, and maintenance mode will let you go back and change them. In a command line install you'd just say /i [msi file] ADDLOCAL=Feature1,Feature2 and so on. If you really want to use "flavor" then internally you'd turn it into an ADDLOCAL list.

这篇关于Wix Installer:在命令行执行MSIEXEC管理员安装时设置组件条件属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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