2014-01-09 78 views
0

我正在進行我的第一個WiX項目,並且我正在經歷一段艱難的時間才能使某些註冊表項正常工作。WiX條件註冊表條目

我的要求是,在安裝程序中有一個選項,以選擇將軟件安裝在臺式計算機上還是飛機上。由於沒有任何方法可以自動檢測它,所以我創建了一個帶有一些單選按鈕的UI屏幕。 (這是一個單獨的文件)

<?xml version="1.0" encoding="utf-8"?> 
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> 
    <Fragment> 
     <UI> 
      <Dialog Id="AircraftDesktopDlg_Custom" 
        Width="370" 
        Height="270" 
        Title="!(loc.InstallDirDlg_Title)"> 
       <Control Type="RadioButtonGroup" 
         Property="InstallType_Prop" 
         Id="InstallType" 
         Width="200" 
         Height="42" 
         X="20" 
         Y="110"> 
        <RadioButtonGroup Property="InstallType_Prop"> 
         <RadioButton Text="Aircraft" 
            Height="17" 
            Value="0" 
            Width="50" 
            X="0" 
            Y="0" /> 
         <RadioButton Text="Desktop" 
            Height="17" 
            Value="1" 
            Width="200" 
            X="0" 
            Y="20" /> 
        </RadioButtonGroup> 
       </Control> 
      </Dialog> 
     </UI> 
    </Fragment> 
</Wix> 

代碼1 - 單選按鈕

然後,在我的主要Product.wxs文件,我有以下。

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> 
    <Product> 
    <Property Id="InstallType_Prop" 
       Value="0"/> 
    . 
    . 
    . 
    <DirectoryRef Id="TARGETDIR"> 
     <Component Id="AircraftRegistryEntries" 
        Guid="E251C37B-2A4F-46D4-8E9F-24C66FB107E9"> 
      <Condition>InstallType_Prop = 0</Condition> 
      <RegistryKey Root="HKLM" 
         Key="Software\Company\Product\v1.0" 
         Action="createAndRemoveOnUninstall"> 
       <RegistryValue Type="integer" 
           Name="OfflineMode" 
           Value="0"/> 
       <RegistryValue Type="integer" 
           Name="Simulator" 
           Value="0"/> 
      </RegistryKey> 
     </Component> 
     <Component Id="DesktopRegistryEntries" 
        Guid="CACDBBB6-BCAA-4B71-92BE-C762325580A3"> 
      <Condition>InstallType_Prop = 1</Condition> 
      <RegistryKey Root="HKLM" 
         Key="Software\Company\Product\v1.0" 
         Action="createAndRemoveOnUninstall"> 
       <RegistryValue Type="integer" 
           Name="OfflineMode" 
           Value="1"/> 
       <RegistryValue Type="integer" 
           Name="Simulator" 
           Value="0"/> 
      </RegistryKey> 
     </Component> 
    </DirectoryRef> 
    . 
    . 
    . 
    <Feature Id='Complete' 
      Level='1'> 
     <ComponentRef Id='AircraftRegistryEntries'/> 
     <ComponentRef Id='DesktopRegistryEntries'/> 
    </Feature> 
</Product> 
</Wix> 

代碼2 - 物業和註冊表項

所以你可以看到,單選按鈕是聯繫在一起的InstallType_Prop。

我想完成的是安裝相應的註冊表項,具體取決於選擇哪個單選按鈕。我在註冊表組件中插入了這些條件,但他們似乎沒有做任何事情。

我甚至不必這樣做 - 我只需要將OfflineMode設置爲1,如果選擇了桌面,並且設置爲0,如果選擇飛行器。

我現在處於虧損狀態,我認爲解決方案存在於自定義操作或評估條件順序的地方,但我並不完全確定。

任何幫助表示讚賞。

回答

0

IMO通常的做法是將不同的組件分成(比方說)兩個特徵,每個系統類型一個,然後用戶看到他們選擇合適的特徵樹。在註冊表項的情況下,每個安裝類型都有一個組件(用於註冊表項),其中一個將在一個功能中,另一個在另一箇中。