ITKeyword,专注技术干货聚合推荐

注册 | 登录

解决c# - WiX: how to access / change installation directory in managed bootstrapper?

itPublisher 分享于

2020腾讯云双十一活动,全年最低!!!(领取3500元代金券),
地址https://cloud.tencent.com/act/cps/redirect?redirect=1073

【阿里云】双十一活动,全年抄底价,限时3天!(老用户也有),
入口地址https://www.aliyun.com/1111/home

I am creating a WPF setup application with a custom user interface. I started with the tutorial of Bryan P. Johnston: http://bryanpjohnston.com/2012/09/28/custom-wix-managed-bootstrapper-application/

Somewhere in my view, I have a simple TextBox that binds to a Property InstallationPath in my MainViewModel.

Now I want this path to be used when the user clicks on "Install". For this, I have a button that binds to my InstallCommand. The following method is called (taken directly from the tutorial):

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

How can I make the packages to be installed into the directory of my property InstallationPath?

Edit:

I found a similar question here on Stackoverflow:

Wix: Specify the INSTALLLOCATION of packages inside the burn managed bootstrapper

The answer there is from Bob Arnson

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

Now, I think I could access the StringVariables in my InstallExecute like this

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

But where to define this variable? I guess somewhere in Product.wxs?

c# wix bootstrapper
edited Feb 22 '13 at 9:31 asked Feb 22 '13 at 7:37 Michael Hilus 429 4 20      Hey Michael, i followed this same tutorial and I'm facing an issue where during major upgrade, the previous exe is not getting removed as new one is installed side by side. I incremented both the EXE version and the included MSIs versions. I saw some other people commenting the same issue below the tutorial. Did you run into this issue? If so how did you get over it? :( Need some help man –  mayooran Apr 27 '16 at 2:31

 | 

2 Answers
2

解决方法

Yes just create a variable in your burn bootstrapper:

<Variable Name="BurnVariable"
          bal:Overridable="yes" />

you can then pass this as a parameter to your boot-strapped msi package:

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

answered Feb 22 '13 at 11:38 caveman_dick 3,483 2 16 38      Thanks! That is exactly what I was looking for. :-) –  Michael Hilus Feb 22 '13 at 16:20

 | 

One missing property "Type" on Bundle Variable element. caverman_dick is right but this not works properly when not overridable. You can try this too, setting Type="string".

Wix Variable Element

<Wix>...<Bundle>...
  <Variable Name="MyApplicationMsiInstallFolder" Value="[WindowsVolume]MyApplication"
          bal:Overridable="yes" Type="string"/>
    <Chain>
        <?if $(var.DbVersion) = false?>
        <PackageGroupRef Id="AccessDatabaseGroup"/>
        <RollbackBoundary />
        <?endif?>
        <MsiPackage Id="MyApplicationMsiPackage" SourceFile="$(var.MyApplicationSetup.TargetPath)" DisplayInternalUI="no"
                                Vital="yes" >
            <MsiProperty Name="APPLICATIONFOLDER" Value="[MyApplicationMsiInstallFolder]"/>
        </MsiPackage>
    </Chain>
</Bundle></Wix>

answered Jun 19 '15 at 2:32 antonio 114 8

 | 


相关阅读排行


相关内容推荐

最新文章

×

×

请激活账号

为了能正常使用评论、编辑功能及以后陆续为用户提供的其他产品,请激活账号。

您的注册邮箱: 修改

重新发送激活邮件 进入我的邮箱

如果您没有收到激活邮件,请注意检查垃圾箱。