Reputation: 325
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>
Upvotes: 4
Views: 7405
Reputation: 219
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"/>
Upvotes: 6