How do I pass a default 'install location'

2020-08-11 20:20发布

问题:

I'm using an rtflicence standard bootstrapper to install dotnet before my poject msi in a chain.

I noticed that there's an 'options' button which displays an install location dialog and allows the user to change the default installation directory.

I need to either:

  1. Prevent this options button from being displayed, or
  2. Populate the install location with a default path, and pass this back to the installer should the user change it.

I read that it's possible to pass Burn variables to msipackages from bootstrapper but I haven't found any further details and would appreciate being pointed in the right direction.

Thanks

回答1:

To go with option 1, you'd have to roll your own BootstrapperApplication and remove the options button from the menu.

Option two is significantly easier to implement. The bootstrapper uses a special Burn variable called InstallFolder to get and set what is in the text block on that view, which you can assign inside the Bundle element.

<Variable Name="InstallFolder" Type="string" Value="[ProgramFilesFolder]"/>

The constant ProgramFilesFolder will set the value of that text block when the program starts, and if the user browses to a different directory, it will be stored in that same variable. To pass it to the MSI, in your chain, you pass the InstallFolder using the MsiProperty tag (INSTALLLOCATION is the name of the property in your WiX project).

<MsiPackage Vital="yes" DisplayName="Your Name" Id="MsiId" SourceFile="path/to/file.msi">
    <MsiProperty Name="INSTALLLOCATION" Value="[InstallFolder]" />
</MsiPackage>


回答2:

I just discovered the SuppressOptionsUI option that addresses your Option 1 without rolling your own BootstrapperApplication:

<?xml version="1.0" encoding="UTF-8"?>

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
 xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">

   <Bundle>
      <BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
         <bal:WixStandardBootstrapperApplication LicenseFile="..\eula.rtf" SuppressOptionsUI="yes"/>
      </BootstrapperApplicationRef>

      <Chain>
      </Chain>
    </Bundle>
</Wix>


回答3:

I think you can try removing the options button by creating a theme. I haven't had to use themes myself but here are two related SO links that may get you pointed in that direction:

WiX bootstrapper theme file?

Theme for my WiX Installer