WiX-如何允许用户更改引导程序上的安装位置

jan*_*han 3 wix bootstrapper wix3.8

我需要允许用户更改安装位置。我已经尝试过这个问题中给出的解决方案

我需要将我的 wix msi 文件添加到我的引导程序项目中。下面是我的 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>
Run Code Online (Sandbox Code Playgroud)

下面是引导程序代码,

<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>
Run Code Online (Sandbox Code Playgroud)

tol*_*gen 5

您使用的是标准引导程序吗?RtfLicense 还是 HyperlinkLicense?

如果您SuppressOptionsUI="no"在 Wix 标准 boostrapper 中设置,这将显示一个选项按钮,允许用户手动修改安装位置。

<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
  <bal:WixStandardBootstrapperApplication
    SuppressOptionsUI="no"
    />
</BootstrapperApplicationRef>
Run Code Online (Sandbox Code Playgroud)

然后,正如您提到在 MSI 包中设置 MSI 属性,这将被用户选择的位置覆盖。

<MsiProperty Name="INSTALLFOLDER" Value="[InstallFolder]" />
Run Code Online (Sandbox Code Playgroud)

如果要设置默认安装位置,请将捆绑包中的变量设置为默认值。

<Variable Name="InstallFolder" Type="string" Value="[ProgramFilesFolder]Install"/>
Run Code Online (Sandbox Code Playgroud)