private void DetectComplete(object sender, DetectCompleteEventArgs e) { // Parse the command line string before any planning. this.ParseCommandLine(); this.root.InstallState = InstallationState.Waiting; if (LaunchAction.Uninstall == WixBA.Model.Command.Action && ResumeType.Arp != WixBA.Model.Command.Resume) // MSI and WixStdBA require some kind of confirmation before proceeding so WixBA should, too. { WixBA.Model.Engine.Log(LogLevel.Verbose, "Invoking automatic plan for uninstall"); WixBA.Plan(LaunchAction.Uninstall); } else if (Hresult.Succeeded(e.Status)) { if (this.Downgrade) { this.root.DetectState = DetectionState.Newer; var relatedPackages = WixBA.Model.BAManifest.Bundle.Packages.Values.Where(p => p.Type == PackageType.UpgradeBundle); var installedVersion = relatedPackages.Any() ? new Version(relatedPackages.Max(p => p.Version)) : null; if (installedVersion != null && installedVersion < new Version(4, 1) && installedVersion.Build > 10) { this.DowngradeMessage = "You must uninstall WiX v" + installedVersion + " before you can install this."; } else { this.DowngradeMessage = "There is already a newer version of WiX installed on this machine."; } } if (LaunchAction.Layout == WixBA.Model.Command.Action) { WixBA.PlanLayout(); } else if (WixBA.Model.Command.Display != Display.Full) { // If we're not waiting for the user to click install, dispatch plan with the default action. WixBA.Model.Engine.Log(LogLevel.Verbose, "Invoking automatic plan for non-interactive mode."); WixBA.Plan(WixBA.Model.Command.Action); } } else { this.root.InstallState = InstallationState.Failed; } // Force all commands to reevaluate CanExecute. // InvalidateRequerySuggested must be run on the UI thread. root.Dispatcher.Invoke(new Action(CommandManager.InvalidateRequerySuggested)); }
public static void PlanLayout() { // Either default or set the layout directory if (String.IsNullOrEmpty(WixBA.Model.Command.LayoutDirectory)) { WixBA.Model.LayoutDirectory = Directory.GetCurrentDirectory(); // Ask the user for layout folder if one wasn't provided and we're in full UI mode if (WixBA.Model.Command.Display == Display.Full) { WixBA.Dispatcher.Invoke((Action) delegate() { WinForms.FolderBrowserDialog browserDialog = new WinForms.FolderBrowserDialog(); browserDialog.RootFolder = Environment.SpecialFolder.MyComputer; // Default to the current directory. browserDialog.SelectedPath = WixBA.Model.LayoutDirectory; WinForms.DialogResult result = browserDialog.ShowDialog(); if (WinForms.DialogResult.OK == result) { WixBA.Model.LayoutDirectory = browserDialog.SelectedPath; WixBA.Plan(WixBA.Model.Command.Action); } else { WixBA.View.Close(); } } ); } } else { WixBA.Model.LayoutDirectory = WixBA.Model.Command.LayoutDirectory; WixBA.Plan(WixBA.Model.Command.Action); } }