2008-09-11 111 views
28

如何將使用WiX安裝的安裝集(MSI)重新升級到與原始安裝相同的文件夾?將WiX安裝集升級到相同的文件夾

作爲升級正確檢測到安裝,但目錄選擇屏幕仍然顯示並且具有默認值(不一定是當前安裝文件夾)。

在首次安裝時,我是否必須手動完成安裝文件夾保存在註冊表項中,然後在升級時讀取此密鑰?如果是這樣,有沒有例子?

還是有一些更簡單的方法來實現MSI或WiX?

作爲參考,我在我目前的WiX文件如下:

<?xml version="1.0" encoding="utf-8"?> 
<Wix xmlns="http://schemas.microsoft.com/wix/2003/01/wi"> 
    <Product Id="a2298d1d-ba60-4c4d-92e3-a77413f54a53" 
      Name="MyCompany Integration Framework 1.0.0" 
      Language="1033" 
      Version="1.0.0" 
      Manufacturer="MyCompany" 
      UpgradeCode="9071eacc-9b5a-48e3-bb90-8064d2b2c45d"> 

     <!-- Package information --> 
     <Package Keywords="Installer" 
       Id="e85e6190-1cd4-49f5-8924-9da5fcb8aee8" 
       Description="Installs MyCompany Integration Framework 1.0.0" 
       Comments="Installs MyCompany Integration Framework 1.0.0" 
       InstallerVersion="100" 
       Compressed="yes" /> 

     <Upgrade Id='9071eacc-9b5a-48e3-bb90-8064d2b2c45d'> 
      <UpgradeVersion Property="PATCHFOUND" 
          OnlyDetect="no" 
          Minimum="0.0.1" 
          IncludeMinimum="yes" 
          Maximum="1.0.0" 
          IncludeMaximum="yes"/> 
     </Upgrade> 

     <!-- Useless but necessary... --> 
     <Media Id="1" Cabinet="MyCompany.cab" EmbedCab="yes" /> 

     <!-- Precondition: .NET 2 must be installed --> 
     <Condition Message='This setup requires the .NET Framework 2 or higher.'> 
      <![CDATA[MsiNetAssemblySupport >= "2.0.50727"]]> 
     </Condition> 

     <Directory Id="TARGETDIR" 
        Name="SourceDir"> 
      <Directory Id="MyCompany" 
         Name="MyCompany"> 
       <Directory Id="INSTALLDIR" 
          Name="Integrat" 
          LongName="MyCompany Integration Framework"> 
        <Component Id="MyCompanyDllComponent" 
           Guid="4f362043-03a0-472d-a84f-896522ce7d2b" 
           DiskId="1"> 
         <File Id="MyCompanyIntegrationDll" 
           Name="IbIntegr.dll" 
           src="..\Build\MyCompany.Integration.dll" 
           Vital="yes" 
           LongName="MyCompany.Integration.dll" /> 
         <File Id="MyCompanyServiceModelDll" 
           Name="IbSerMod.dll" 
           src="..\Build\MyCompany.ServiceModel.dll" 
           Vital="yes" 
           LongName="MyCompany.ServiceModel.dll" /> 
        </Component> 

        <!-- More components --> 
       </Directory> 
      </Directory> 
     </Directory> 

     <Feature Id="MyCompanyProductFeature" 
       Title='MyCompany Integration Framework' 
       Description='The complete package' 
       Display='expand' 
       Level="1" 
       InstallDefault='local' 
       ConfigurableDirectory="INSTALLDIR"> 
      <ComponentRef Id="MyCompanyDllComponent" /> 
     </Feature> 

     <!-- Task scheduler application. It has to be used as a property --> 
     <Property Id="finaltaskexe" 
        Value="MyCompany.Integration.Host.exe" /> 
     <Property Id="WIXUI_INSTALLDIR" 
        Value="INSTALLDIR" /> 

     <InstallExecuteSequence> 
      <!-- command must be executed: MyCompany.Integration.Host.exe /INITIALCONFIG parameters.xml --> 
      <Custom Action='PropertyAssign' 
        After='InstallFinalize'>NOT Installed AND NOT PATCHFOUND</Custom> 
      <Custom Action='LaunchFile' 
        After='InstallFinalize'>NOT Installed AND NOT PATCHFOUND</Custom> 

      <RemoveExistingProducts Before='CostInitialize' /> 
     </InstallExecuteSequence> 

     <!-- execute comand --> 
     <CustomAction Id='PropertyAssign' 
         Property='PathProperty' 
      Value='[INSTALLDIR][finaltaskexe]' /> 
     <CustomAction Id='LaunchFile' 
         Property='PathProperty' 
         ExeCommand='/INITIALCONFIG "[INSTALLDIR]parameters.xml"' 
         Return='asyncNoWait' /> 

     <!-- User interface information --> 
     <UIRef Id="WixUI_InstallDir" /> 
     <UIRef Id="WixUI_ErrorProgressText" /> 
    </Product> 
</Wix> 

回答

31

有一個在WiX的教程中的例子:http://wix.tramontana.co.hu/tutorial/getting-started/where-to-install

<Property Id="INSTALLDIR"> 
    <RegistrySearch Id='AcmeFoobarRegistry' Type='raw' 
    Root='HKLM' Key='Software\Acme\Foobar 1.0' Name='InstallDir' /> 
</Property> 

當然,你必須設置註冊表項作爲安裝的一部分。將其粘貼在原始安裝的一部分內:

<RegistryKey 
     Key="Software\Software\Acme\Foobar 1.0" 
     Root="HKLM"> 
    <RegistryValue Id="FoobarRegInstallDir" 
      Type="string" 
      Name="InstallDir" 
      Value="[INSTALLDIR]" /> 
</RegistryKey> 
+0

我已經實現了這一點,它的工作原理。謝了哥們。 – 2008-09-18 14:15:27

+1

指向教程的鏈接已更改爲:http://wix.tramontana.co.hu/tutorial/getting-started/where-to-install – marcin 2011-11-09 12:39:17

5

'Registry'已棄用。現在的代碼部分應該是這樣的:

<RegistryKey Id="FoobarRegRoot" 
      Action="createAndRemoveOnUninstall" 
      Key="Software\Software\Acme\Foobar 1.0" 
      Root="HKLM"> 
    <RegistryValue Id="FoobarRegInstallDir" 
       Type="string" 
       Name="InstallDir" 
       Value="[INSTALLDIR]" /> 
</RegistryKey> 
4

你並不真正需要的RegistryKey從RegistryValue在一個簡單的情況下,這樣的分離。此外,使用HKMU而不是HKLM可以處理您是否正在進行機器或用戶安裝。

<RegistryValue 
    Root="HKMU" 
    Key="Software\[Manufacturer]\[ProductName]" 
    Name="InstallDir" 
    Type="string" 
    Value="[INSTALLDIR]" 
    KeyPath="yes" /> 
相關問題