Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WiX: how to access / change installation directory in managed bootstrapper?

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:

Specify the INSTALLLOCATION of packages in WiX 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?

like image 951
Michael Hilus Avatar asked Feb 22 '13 07:02

Michael Hilus


1 Answers

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>
like image 118
caveman_dick Avatar answered Sep 29 '22 03:09

caveman_dick