Hi Rob, Thank You for the insight on using PlanPackageBegin event. I tried your recommendation in my wpf app, but haven't had much success. I have a simple wix ba project that contains one bundle and chain element. In my PlanPackageBegin event I have added source code to check for Netfx4Full. The problem here is that my PlanPackageBegin operation is never called. Although it has been subscribed to an event in my constructor. Where did I go wrong here in my implementation. I've added code for reference below: Wix Code: <?xml version="1.0" encoding="UTF-8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"> <Bundle Name="My Test Application" Version="1.0.0.0" Manufacturer="lino" UpgradeCode="C82A383C-751A-43B8-90BF-A250F7BC2863">
<Variable Name ="AToInstall" bal:Overridable="yes" Value="A" Type="string"/> <BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost"> <Payload SourceFile="..\TestBA\BootstrapperCore.config"/> <Payload SourceFile="..\TestBA\bin\Debug\TestBA.dll"/> <Payload SourceFile="..\TestBA\bin\Debug\GalaSoft.MvvmLight.WPF4.dll"/> <Payload SourceFile="C:\Program Files (x86)\WiX Toolset v3.8\SDK\Microsoft.Deployment.WindowsInstaller.dll"/> </BootstrapperApplicationRef> <Chain> <PackageGroupRef Id='Netfx4Full' /> <MsiPackage Id="DummyInstallationPackageId" SourceFile="..\DummyInstaller\bin\Release\DummyInstaller.msi" Cache="yes" Visible="no"/> </Chain> </Bundle> <Fragment> <WixVariable Id="WixMbaPrereqPackageId" Value="Netfx4Full" /> <WixVariable Id="WixMbaPrereqLicenseUrl" Value="NetfxLicense.rtf" /> <util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full" Value="Version" Variable="Netfx4FullVersion" /> <util:RegistrySearch Root="HKLM" Key="SOFTWARE\Microsoft\Net Framework Setup\NDP\v4\Full" Value="Version" Variable="Netfx4x64FullVersion" Win64="yes" /> <PackageGroup Id="Netfx4Full"> <ExePackage Id="Netfx4Full" Cache="no" Compressed="yes" PerMachine="yes" Permanent="yes" Vital="yes" SourceFile="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\DotNetFX40\dotNetFx40_Full_x86_x64.exe" DownloadUrl="http://go.microsoft.com/fwlink/?LinkId=164193" DetectCondition="Netfx4FullVersion AND (NOT VersionNT64 OR Netfx4x64FullVersion)" /> </PackageGroup> </Fragment> </Wix> C# wpf MainViewModel code: using Microsoft.Tools.WindowsInstallerXml.Bootstrapper; using GalaSoft.MvvmLight; using GalaSoft.MvvmLight.Command; using System; namespace Examples.Bootstrapper { public class MainViewModel : ViewModelBase { //constructor public MainViewModel(BootstrapperApplication bootstrapper) { System.Threading.Thread.Sleep(10000); this.IsThinking = false; this.Bootstrapper = bootstrapper; this.Bootstrapper.ApplyComplete += this.OnApplyComplete; this.Bootstrapper.DetectPackageComplete += this.OnDetectPackageComplete; this.Bootstrapper.PlanPackageBegin += this.PlanPackageBegin; this.Bootstrapper.PlanComplete += this.OnPlanComplete; } #region Properties private bool installAEnabled; public bool InstallAEnabled { get { return installAEnabled; } set { installAEnabled = value; RaisePropertyChanged("InstallAEnabled"); } } private bool installBEnabled; public bool InstallBEnabled { get { return installBEnabled; } set { installBEnabled = value; RaisePropertyChanged("InstallBEnabled"); } } private bool uninstallEnabled; public bool UninstallEnabled { get { return uninstallEnabled; } set { uninstallEnabled = value; RaisePropertyChanged("UninstallEnabled"); } } private bool isThinking; public bool IsThinking { get { return isThinking; } set { isThinking = value; RaisePropertyChanged("IsThinking"); } } public BootstrapperApplication Bootstrapper { get; private set; } #endregion //Properties #region Methods private void InstallAExecute() { IsThinking = true; Bootstrapper.Engine.StringVariables["AToInstall"] = "A"; Bootstrapper.Engine.Plan(LaunchAction.Install); } private void InstallBExecute() { IsThinking = true; Bootstrapper.Engine.StringVariables["BToInstall"] = "B"; Bootstrapper.Engine.Plan(LaunchAction.Install); } private void UninstallExecute() { IsThinking = true; Bootstrapper.Engine.StringVariables["AToInstall"] = "A"; Bootstrapper.Engine.StringVariables["BToInstall"] = "B"; Bootstrapper.Engine.Plan(LaunchAction.Uninstall); } private void ExitExecute() { TestBA.BootstrapperDispatcher.InvokeShutdown(); } /// <summary> /// Method that gets invoked when the Bootstrapper ApplyComplete event is fired. /// This is called after a bundle installation has completed. Make sure we updated the view. /// </summary> private void OnApplyComplete(object sender, ApplyCompleteEventArgs e) { IsThinking = false; InstallAEnabled = false; InstallBEnabled = false; UninstallEnabled = false; } private void PlanPackageBegin(object sender, PlanPackageBeginEventArgs e) { // Turns off .NET install when setting up the install plan as we already have it. //if (e.PackageId.Equals(ba.Engine.StringVariables["WixMbaPrereqPackageId"], StringComparison.Ordinal)) if (e.PackageId.Equals("Netfx4Full", StringComparison.Ordinal)) { e.State = RequestState.None; } } /// <summary> /// Method that gets invoked when the Bootstrapper DetectPackageComplete event is fired. /// Checks the PackageId and sets the installation scenario. The PackageId is the ID /// specified in one of the package elements (msipackage, exepackage, msppackage, /// msupackage) in the WiX bundle. /// </summary> private void OnDetectPackageComplete(object sender, DetectPackageCompleteEventArgs e) { if (e.PackageId == "DummyInstallationPackageId") { if (e.State == PackageState.Absent) { InstallAEnabled = true; InstallBEnabled = true; } else if (e.State == PackageState.Present) UninstallEnabled = true; } } /// <summary> /// Method that gets invoked when the Bootstrapper PlanComplete event is fired. /// If the planning was successful, it instructs the Bootstrapper Engine to /// install the packages. /// </summary> private void OnPlanComplete(object sender, PlanCompleteEventArgs e) { if (e.Status >= 0) Bootstrapper.Engine.Apply(System.IntPtr.Zero); } #endregion //Methods #region RelayCommands private RelayCommand installACommand; public RelayCommand InstallACommand { get { if (installACommand == null) installACommand = new RelayCommand(() => InstallAExecute(), () => InstallAEnabled == true); return installACommand; } } private RelayCommand installBCommand; public RelayCommand InstallBCommand { get { if (installBCommand == null) installBCommand = new RelayCommand(() => InstallBExecute(), () => InstallBEnabled == true); return installBCommand; } } private RelayCommand uninstallCommand; public RelayCommand UninstallCommand { get { if (uninstallCommand == null) uninstallCommand = new RelayCommand(() => UninstallExecute(), () => UninstallEnabled == true); return uninstallCommand; } } private RelayCommand exitCommand; public RelayCommand ExitCommand { get { if (exitCommand == null) exitCommand = new RelayCommand(() => ExitExecute()); return exitCommand; } } #endregion //RelayCommands } } TestBA.cs code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Threading; using Microsoft.Tools.WindowsInstallerXml.Bootstrapper; namespace Examples.Bootstrapper { public class TestBA : BootstrapperApplication { // global dispatcher static public Dispatcher BootstrapperDispatcher { get; private set; } // entry point for our custom UI protected override void Run() { this.Engine.Log(LogLevel.Verbose, "Launching custom TestBA UX"); BootstrapperDispatcher = Dispatcher.CurrentDispatcher; MainViewModel viewModel = new MainViewModel(this); viewModel.Bootstrapper.Engine.Detect(); MainView view = new MainView(); view.DataContext = viewModel; view.Closed += (sender, e) => BootstrapperDispatcher.InvokeShutdown(); view.Show(); Dispatcher.Run(); this.Engine.Quit(0); } } } <http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/file/n7596158/snapshot.jpg> Kudos to http://bryanpjohnston.com/2012/09/28/custom-wix-managed-bootstrapper-application/ for sharing his example. -- View this message in context: http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Passing-Variables-from-C-custom-BA-to-WIX-tp7596113p7596158.html Sent from the wix-users mailing list archive at Nabble.com. ------------------------------------------------------------------------------ Want fast and easy access to all the code in your enterprise? Index and search up to 200,000 lines of code with a free copy of Black Duck Code Sight - the same software that powers the world's largest code search on Ohloh, the Black Duck Open Hub! Try it now. http://p.sf.net/sfu/bds _______________________________________________ WiX-users mailing list WiX-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/wix-users