1
votes

I have a Bootstrapper with WPF Custom UI. It contains NET Framework 4.5 package and my product msi package. I'd like to provide folder selection dialog in my UI and then replace default installation folder with selected by user. For it I need to read the value from msi, show dialog and then replace.

How I can do it in WPF UI? This way I cannot get value:

 if (engine.StringVariables.Contains("INSTALLFOLDER"))
                    installdir2 = engine.StringVariables["INSTALLFOLDER"];

Is it possible to do?

1

1 Answers

1
votes

It is not possible to directly read install folder from msi(i mean, with relative ease), but you can do the following:

  1. In Bundle.wxs, add MsiProperty to the package declaration:

    <MsiPackage  Id="Installer"  Compressed="yes" Vital="yes" ForcePerMachine="yes" SourceFile="..\Installer\bin\$(var.Configuration)\Installer.msi">
                <MsiProperty Name='INSTALLFOLDER' Value='[InstallFolder]' />
    

where INSTALLFOLDER - variable in your Wix installer, InstallFolder - Engine variable name.

  1. In installer, store your INSTALLFOLDER property in registry on install(or in place, where you can easily get it from while updating/repairing/etc)

  2. In bootstrapper, set the default value for your InstallFolder property.

  3. Before Apply, call Engine.StringVariables["InstallFolder"]=your_value
  4. You are done