4

I need to allow user to change install location. I have tried solution given in this question

I need to add my wix msi file into my bootstrapper project. below is the my msi project code,

    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <MediaTemplate />

    <Feature Id="ProductFeature" Title="SetupProject1" Level="1">
        <ComponentRef Id="ProductComponent" />
    </Feature>
</Product>

<Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir" src="[TARGETDIR]">
            <Directory Id="INSTALLFOLDER" Name="SetupProject1">
      <Component Id="ProductComponent" Guid="2ACAD378-270B-4B50-AAED-A234A6BB8276">
        <File Name="$(var.WindowsFormsApplication2.TargetFileName)" Source="$(var.WindowsFormsApplication2.TargetPath)" />
      </Component>
    </Directory>
    </Directory>
</Fragment>

<Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
    </ComponentGroup>
</Fragment>

and below is the bootstrapper code,

<Variable Name="varInstallLocation" bal:Overridable="yes" />

    <Chain>
  <MsiPackage 
    Id="MyService" 
    Name="MyService" 
    SourceFile="..\SetupProject1\bin\Release\SetupProject1.msi" 
    DisplayInternalUI="yes" 
    EnableFeatureSelection="yes"
    Compressed="yes"
    Vital="yes" >
  <MsiProperty Name="TARGETDIR" Value="[varInstallLocation]"/>
  </MsiPackage>
    </Chain>
</Bundle>
Community
  • 1
  • 1
janitheshan
  • 325
  • 2
  • 11
  • 25

1 Answers1

5

Are you using a standard bootstrapper? RtfLicense or HyperlinkLicense?

If you set SuppressOptionsUI="no" within the Wix standard boostrapper, this will show an options button which will allow the user to amend the install location manually.

<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
  <bal:WixStandardBootstrapperApplication
    SuppressOptionsUI="no"
    />
</BootstrapperApplicationRef>

Then as you mentioned setup a MSI property within the MSI package, this will then be overwritten with the location the user has picked.

<MsiProperty Name="INSTALLFOLDER" Value="[InstallFolder]" />

If you want to setup a default install location set a Variable within the bundle to your default value.

<Variable Name="InstallFolder" Type="string" Value="[ProgramFilesFolder]Install"/>
tollgen
  • 209
  • 1
  • 4
  • 15
  • I can't set the default install location. I'm using the RtfLicense template and I set the Variable (inside Bundle but outside Chain) but the initial install folder is empty. – bubi Sep 17 '17 at 16:21