Вопрос

I'm using WiX 3.6 ( but could upgrade to 3.8 if necessary ) and have a bootsrapper written in BURN, that's nearly doing everything I need, except this one issue; which I just can't seem to crack.

I have two variables; Product_XYZ and Product_ABC. The first one contains a folder path populated via a registry search ( so it may be blank, if the search didn't find my reg key ) and the other one is hard-coded ( ie "[ProgramFilesFolder]\ABC" ).

I simply (?) want to set the InstallFolder variable ( so that it appears in the UI via the Options button ) to the value in the Product_XYZ variable ( if it's not blank ). If it is blank, I want to set the InstallFolder to the value in Product_ABC.

ie

If Product_XYZ <> "" then
    InstallFolder = [Product_XYZ]
else
    InstallFolder = [Product_ABC]
endif 

but obviously using BURN logic !!

Can anyone please help me ?

Cheers,

Chris.

Это было полезно?

Решение

I had the same need and found a solution by looking at WiX's own bundle:

    <Variable
      Name='InstallFolder'
      Type='string'
      Value='[ProgramFilesFolder]WiX Toolset v$(var.WixMajorMinor)' />
    <util:RegistrySearch
      Id="PreviousInstallFolderSearch"
      Root='HKLM'
      Key='SOFTWARE\Microsoft\Windows Installer XML\$(var.WixMajorMinor)'
      Value='InstallFolder'
      Variable='PreviousInstallFolder' />
    <util:DirectorySearch
      Path='[PreviousInstallFolder]'
      Variable='InstallFolder'
      After='PreviousInstallFolderSearch'
      Condition='PreviousInstallFolder' />

The <Variable/> element defines the default value.

The <util:RegistrySearch/> looks for the registry value (and, if found, saves it in a new variable called PreviousInstallFolder).

The <util:DirectorySearch/> executes only if the registry key was found. It checks that the directory exists and sets InstallFolder if it does.

Note that if the registry value exists, but the directory it specifies does not exist, then the default value will be used instead.

Другие советы

  1. You should test your MSI (without Burn) if you have set it up correctly and that install location can be altered via Property Based on your directory setup, this is just an example:

    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder>
             <Directory ID="INSTALLDIR" Name="FolderName" />
    ...
    </Directory>
    

    Test your msi with msiexec, example:

    msiexec /i package.msi /qb+ INSTALLDIR="C:\Programs\ABC"
    

    If it doesn't install in the location you have specified then first you need to fix your WiX msi so that it can accept INSTALLDIR.

  2. In Burn after you set the variable (InstallFolder) conditionally you need to pass it to MSIpackage by using the MsiProperty element. For example

    <MsiPackage Id="someid" Source="$(var.msi)Yourinstaller.msi">
        <MsiProperty Name="INSTALLDIR" Value="[InstallFolder]" />
    

Note, when you send INSTALLDIR property path to msi it has to be full path.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top