簡體   English   中英

根據條件在WiX中設置屬性

[英]Set a property in WiX based on a condition

應該很容易,但幾個小時后我就空白了。

我做了一個注冊表搜索(實際上是兩個),因為我需要檢查前兩個安裝中的任何一個,然后將我的新文件安裝到找到的先前安裝的位置。

  • 這些先前安裝中只有一個實際存在。

然后我需要將我的新文件安裝到找到'PROD#'的'InstallLocation'。

<!—  Look for the UnInstall key of the 1st possible product  -->
<!—  GUID = {E928E024-DEFE-41A7-8469-D338212C4943}           -->
<Property Id='PROD1'>
    <RegistrySearch Id='PROD_REG1'
                    Type='raw'
                    Root='HKLM'
                    Key='$(var.REGKEY_PROD1)'
                    Name='InstallLocation' />
</Property>

<!—  Look for the UnInstall key of the 2nd possible product  -->
<!—  GUID = {A40A9018-DB9D-4588-A591-F012600C6300}           -->
<Property Id='PROD2'>
  <RegistrySearch Id='PROD_REG2'
                  Type='raw'
                  Root='HKLM'
                  Key='$(var.REGKEY_PROD2)'
                  Name='InstallLocation' />
    </Property>

<!--  How do I set INSTALL_HERE Property to whichever ‘InstallLocation’ was found?  -->

<!--  Define the directory structure  -->
<Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="INSTALL_HERE">
        <Directory Id="MAIN_DIRECTORY" Name="MyProduct"/>
        <Directory Id="HELP_DIRECTORY" Name="Help"/>
    </Directory>
</Directory>

以下內容將屬性A和B設置為兩個不同注冊表搜索的結果。 如果搜索B成功,則它將覆蓋A的值,其值為B.

  <Property Id="A">
     <!-- registry search 1 here -->
  </Property>

  <Property Id="B">
     <!-- registry search 2 here -->
  </Property>

  <SetProperty Id="A" After="AppSearch" Value="[B]">
     B
  </SetProperty>

注意SetProperty元素如何使用B的值兩次:一次為Value="[B]"以覆蓋A的值,一次作為自定義操作的條件文本。 After="AppSearch"確保在注冊表搜索后立即執行自定義操作。

另見Rob Mensching的答案

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM