Wix-根据条件安装目录 [英] Wix - install directory depending on a condition

查看:240
本文介绍了Wix-根据条件安装目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的wix源代码中,我必须在注册表中查找2个条目以获取安装目录:

In my wix source code, I have to look for 2 entries in the registry to get an install directory :

<Property Id="INSTALLDIR_A"> 
 <RegistrySearch Id='RegA' Type='raw' 
   Root='HKLM' Key='Software\Path\To\A' Name='InstallLocation' /> 

 <Property Id="INSTALLDIR_B"> 
 <RegistrySearch Id='RegB' Type='raw' 
   Root='HKLM' Key='Software\Path\To\B' Name='InstallLocation' /> 

我的安装目录必须是INSTALLDIR_A或INSTALLDIR_B。如果我只看1个条目,那么我会像这样实现它:

My install directory must be either INSTALLDIR_A or INSTALLDIR_B. If I had to look only to 1 entry, I would have implemented it like that :

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="INSTALLDIR" Name="My path">
    <!-- further code -->
  </Directory>
</Directory>

但是我希望INSTALLDIR是INSTALLDIR_A还是INSTALLDIR_B,具体取决于定义的那个。如何实现这一目标?

But I want INSTALLDIR to be either INSTALLDIR_A or INSTALLDIR_B depending on which one is defined. How to achieve this ?

推荐答案

有一个自定义操作SetDirectory( http://wixtoolset.org/documentation/manual/v3/xsd/wix/setdirectory.html )。您可以尝试将第一个值用作默认值,如果设置了另一个则覆盖它:

There's a custom action SetDirectory (http://wixtoolset.org/documentation/manual/v3/xsd/wix/setdirectory.html) for that. You might try something like using the first value as default and overwriting it if the other one is set:

<Fragment>
  <Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="ProgramFilesFolder">
      <Directory Id="INSTALLFOLDER" Name="Software\Path\To\A" />
    </Directory>
  </Directory>

  <SetDirectory Id="INSTALLFOLDER" Value="[INSTALLDIR_B]">INSTALLDIR_B AND NOT INSTALLDIR_A</SetDirectory>
</Fragment>

这篇关于Wix-根据条件安装目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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