WiX:如何访问/更改托管引导程序中的安装目录?

Mic*_*lus 5 c# wix bootstrapper

我正在创建一个带有自定义用户界面的WPF设置应用程序.我从Bryan P. Johnston的教程开始:http://bryanpjohnston.com/2012/09/28/custom-wix-managed-bootstrapper-application/

在我看来的某个地方,我有一个简单的TextBox绑定到InstallationPath我的房产MainViewModel.

现在,我希望在用户单击"安装"时使用此路径.为此,我有一个绑定到我的按钮InstallCommand.调用以下方法(直接从教程中获取):

private void InstallExecute()
{
    Bootstrapper.Engine.Plan(LaunchAction.Install);
}
Run Code Online (Sandbox Code Playgroud)

如何将软件包安装到我的属性目录中InstallationPath


编辑:

我在Stackoverflow上发现了一个类似的问题:

在Burn托管引导程序内指定WiX中的软件包的INSTALLLOCATION

答案来自Bob Arnson

为每个MsiPackage使用MsiProperty子项指定INSTALLLOCATION = [BurnVariable].然后使用Engine.StringVariables设置BurnVariable.

现在,我想我可以访问StringVariables我的InstallExecute喜欢这个

private void InstallExecute()
{
    Bootstrapper.Engine.StringVariables["BurnVariable"] = InstallationPath;
    Bootstrapper.Engine.Plan(LaunchAction.Install);
}
Run Code Online (Sandbox Code Playgroud)

但是在哪里定义这个变量?我想在Product.wxs的某个地方?

cav*_*ick 7

是的,只需在刻录引导程序中创建一个变量:

<Variable Name="BurnVariable"
          bal:Overridable="yes" />
Run Code Online (Sandbox Code Playgroud)

然后,您可以将此参数作为参数传递给引导程序的msi程序包:

<MsiPackage SourceFile="$(var.YourMsiProject.Installer.TargetPath)" Compressed="no">
    <MsiProperty Name="INSTALLLOCATION" Value="[BurnVariable]" />          
</MsiPackage>
Run Code Online (Sandbox Code Playgroud)