加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 08:26:29 所属栏目:百科 来源:网络整理
导读:我正在创建一个带有自定义用户界面的 WPF设置应用程序.我从Bryan P. Johnston教程开始: http://bryanpjohnston.com/2012/09/28/custom-wix-managed-bootstrapper-application/ 在我看来,我有一个简单的TextBox绑定到MainViewModel中的Property Installation
我正在创建一个带有自定义用户界面的 WPF设置应用程序.我从Bryan P. Johnston教程开始: http://bryanpjohnston.com/2012/09/28/custom-wix-managed-bootstrapper-application/

在我看来,我有一个简单的TextBox绑定到MainViewModel中的Property InstallationPath.

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

private void InstallExecute()
{
    Bootstrapper.Engine.Plan(LaunchAction.Install);
}

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

编辑:

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

Specify the INSTALLLOCATION of packages in WiX inside the Burn managed bootstrapper

答案来自Bob Arnson

Use an MsiProperty child for each MsiPackage to specify INSTALLLOCATION=[BurnVariable]. Then use Engine.StringVariables to set BurnVariable.

现在,我想我可以像这样访问InstallExecute中的StringVariables

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

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

解决方法

是的,只需在刻录引导程序中创建一个变量:
<Variable Name="BurnVariable"
          bal:Overridable="yes" />

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

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读