我需要允许用户更改安装位置。我试过这个question
中给出的解决方案我需要将我的wix msi文件添加到我的bootstrapper项目中。 下面是我的msi项目代码,
<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>
及以下是引导程序代码,
<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>
答案 0 :(得分:4)
您使用的是标准引导程序吗? RtfLicense还是HyperlinkLicense?
如果在Wix标准boostrapper中设置SuppressOptionsUI="no"
,则会显示一个选项按钮,允许用户手动修改安装位置。
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
<bal:WixStandardBootstrapperApplication
SuppressOptionsUI="no"
/>
</BootstrapperApplicationRef>
然后,正如您提到的在MSI包中设置MSI属性,然后将覆盖用户选择的位置。
<MsiProperty Name="INSTALLFOLDER" Value="[InstallFolder]" />
如果要设置默认安装位置,请将捆绑中的变量设置为默认值。
<Variable Name="InstallFolder" Type="string" Value="[ProgramFilesFolder]Install"/>