private void BuildRocketUE_Click(object sender, RoutedEventArgs e)
        {
            bLastBuildSuccess = false;

            if (bIsBuilding)
            {
                AutomationToolProcess.Kill();
                return;
            }

            if (EngineVersionSelection.SelectedIndex == 0)
            {
                MessageBox.Show("Please select your Engine version to build. If you are unsure about the version number look into the following file:\n\n/Engine/Source/Runtime/Launch/Resources/Version.h\n\nAnd check ENGINE_MAJOR_VERSION and ENGINE_MINOR_VERSION.", "Select Engine Version.", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

            ChangeStatusLabel("Preparing to build...");

            if (postBuildSettings.ShouldSaveToZip() && postBuildSettings.DirectoryIsWritable() == false)
            {
                MessageBox.Show(string.Format("You chose to save Engine build as a zip file but below directory is either not available or not writable.\n\n{0}", postBuildSettings.ZipPath.Text), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (CustomBuildXMLFile.Text != DEFAULT_BUILD_XML_FILE)
            {
                if (CustomBuildXMLFile.Text == string.Empty)
                {
                    ChangeStatusLabel("Error. Empty build xml file.");
                    MessageBox.Show(string.Format("Build XML cannot be empty.\n\nIf you don't have a custom build file, press \"Reset to default\" to use default InstalledEngineBuild.xml", CustomBuildXMLFile.Text), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                if (File.Exists(CustomBuildXMLFile.Text) == false)
                {
                    ChangeStatusLabel("Error. Build xml does not exist.");
                    MessageBox.Show(string.Format("Build XML {0} does not exist!", CustomBuildXMLFile.Text), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }

            if (SupportHTML5() == false && bWithHTML5.IsChecked == true)
            {
                bWithHTML5.IsChecked = false;
                MessageBox.Show("HTML5 support was removed from Unreal Engine 4.24 and higher. You had it enabled but since it is of no use, I disabled it.");
            }

            if (MessageBox.Show("You are going to build a binary version of Unreal Engine 4. This is a long process and might take time to finish. Are you sure you want to continue? ", "Build Binary Version", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                if (bWithDDC.IsChecked == true)
                {
                    MessageBoxResult MessageResult = MessageBox.Show("Building Derived Data Cache (DDC) is one of the slowest aspect of the build. You can skip this step if you want to. Do you want to continue with DDC enabled?\n\nPress Yes to continue with build\nPress No to continue without DDC\nPress Cancel to stop build", "Warning", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning);

                    switch (MessageResult)
                    {
                    case MessageBoxResult.No:
                        bWithDDC.IsChecked = false;
                        break;

                    case MessageBoxResult.Cancel:
                        return;

                    default:
                        break;
                    }
                }

                LogControl.ClearAllLogs();
                AddLogEntry(string.Format("Welcome to UE4 Binary Builder v{0}", PRODUCT_VERSION));
                BuildRocketUE.Content = "Stop Build";

                if (GameConfigurations.Text == "")
                {
                    GameConfigurations.Text = "Development;Shipping";
                }

                string BuildXMLFile = CustomBuildXMLFile.Text;
                if (BuildXMLFile != DEFAULT_BUILD_XML_FILE)
                {
                    BuildXMLFile = string.Format("\"{0}\"", CustomBuildXMLFile.Text);
                }

                string CommandLineArgs = string.Format("BuildGraph -target=\"Make Installed Build Win64\" -script={0} -set:WithDDC={1} -set:SignExecutables={2} -set:EmbedSrcSrvInfo={3} -set:GameConfigurations={4} -set:WithFullDebugInfo={5}",
                                                       BuildXMLFile,
                                                       GetConditionalString(bWithDDC.IsChecked),
                                                       GetConditionalString(bSignExecutables.IsChecked),
                                                       GetConditionalString(bEnableSymStore.IsChecked),
                                                       GameConfigurations.Text,
                                                       GetConditionalString(bWithFullDebugInfo.IsChecked));

                if (bWithDDC.IsChecked == true && bHostPlatformDDCOnly.IsChecked == true)
                {
                    CommandLineArgs += " -set:HostPlatformDDCOnly=true";
                }

                if (bHostPlatformOnly.IsChecked == true)
                {
                    CommandLineArgs += " -set:HostPlatformOnly=true";
                }
                else
                {
                    if (SupportHTML5())
                    {
                        CommandLineArgs += string.Format(" -set:WithWin64={0} -set:WithWin32={1} -set:WithMac={2} -set:WithAndroid={3} -set:WithIOS={4} -set:WithTVOS={5} -set:WithLinux={6} -set:WithHTML5={7} -set:WithSwitch={8} -set:WithPS4={9} -set:WithXboxOne={10} -set:WithLumin={11}",
                                                         GetConditionalString(bWithWin64.IsChecked),
                                                         GetConditionalString(bWithWin32.IsChecked),
                                                         GetConditionalString(bWithMac.IsChecked),
                                                         GetConditionalString(bWithAndroid.IsChecked),
                                                         GetConditionalString(bWithIOS.IsChecked),
                                                         GetConditionalString(bWithTVOS.IsChecked),
                                                         GetConditionalString(bWithLinux.IsChecked),
                                                         GetConditionalString(bWithHTML5.IsChecked),
                                                         GetConditionalString(bWithSwitch.IsChecked),
                                                         GetConditionalString(bWithPS4.IsChecked),
                                                         GetConditionalString(bWithXboxOne.IsChecked),
                                                         GetConditionalString(bWithLumin.IsChecked));
                    }
                    else
                    {
                        CommandLineArgs += string.Format(" -set:WithWin64={0} -set:WithWin32={1} -set:WithMac={2} -set:WithAndroid={3} -set:WithIOS={4} -set:WithTVOS={5} -set:WithLinux={6} -set:WithSwitch={7} -set:WithPS4={8} -set:WithXboxOne={9} -set:WithLumin={10}",
                                                         GetConditionalString(bWithWin64.IsChecked),
                                                         GetConditionalString(bWithWin32.IsChecked),
                                                         GetConditionalString(bWithMac.IsChecked),
                                                         GetConditionalString(bWithAndroid.IsChecked),
                                                         GetConditionalString(bWithIOS.IsChecked),
                                                         GetConditionalString(bWithTVOS.IsChecked),
                                                         GetConditionalString(bWithLinux.IsChecked),
                                                         GetConditionalString(bWithSwitch.IsChecked),
                                                         GetConditionalString(bWithPS4.IsChecked),
                                                         GetConditionalString(bWithXboxOne.IsChecked),
                                                         GetConditionalString(bWithLumin.IsChecked));
                    }

                    if (SupportLinuxAArch64())
                    {
                        CommandLineArgs += string.Format(" -set:WithLinuxAArch64={0}", GetConditionalString(bWithLinuxAArch64.IsChecked));
                    }
                }

                if (EngineVersionSelection.SelectedIndex > 1)
                {
                    CommandLineArgs += string.Format(" -set:WithServer={0} -set:WithClient={1} -set:WithHoloLens={2}",
                                                     GetConditionalString(bWithServer.IsChecked),
                                                     GetConditionalString(bWithClient.IsChecked),
                                                     GetConditionalString(bWithHoloLens.IsChecked));
                }

                if (BuildXMLFile != DEFAULT_BUILD_XML_FILE && CustomOptions.Text != string.Empty)
                {
                    CommandLineArgs += string.Format(" {0}", CustomOptions.Text);
                    AddLogEntry("Using custom options...");
                }

                if (bCleanBuild.IsChecked == true)
                {
                    CommandLineArgs += " -Clean";
                }

                AddLogEntry(string.Format("Commandline: {0}\n", CommandLineArgs));
                ProcessStartInfo AutomationStartInfo = new ProcessStartInfo
                {
                    FileName               = AutomationExePath,
                    Arguments              = CommandLineArgs,
                    UseShellExecute        = false,
                    CreateNoWindow         = true,
                    RedirectStandardError  = true,
                    RedirectStandardOutput = true
                };

                DispatchTimer.Start();
                StopwatchTimer.Start();

                AutomationToolProcess                     = new Process();
                AutomationToolProcess.StartInfo           = AutomationStartInfo;
                AutomationToolProcess.EnableRaisingEvents = true;
                AutomationToolProcess.OutputDataReceived += new DataReceivedEventHandler(AutomationToolProcess_OutputDataReceived);
                AutomationToolProcess.ErrorDataReceived  += new DataReceivedEventHandler(AutomationToolProcess_ErrorDataReceived);
                AutomationToolProcess.Exited             += new EventHandler(AutomationToolProcess_Exited);
                AutomationToolProcess.Start();
                AutomationToolProcess.BeginErrorReadLine();
                AutomationToolProcess.BeginOutputReadLine();

                bIsBuilding = true;
                ChangeStatusLabel("Building...");
            }
        }
        private void BuildRocketUE_Click(object sender, RoutedEventArgs e)
        {
            bLastBuildSuccess = false;

            if (bIsBuilding)
            {
                GameAnalyticsCSharp.AddDesignEvent("Build:AutomationTool:Killed");
                AutomationToolProcess.Kill();
                return;
            }

            if (FinalBuildPath == null && string.IsNullOrWhiteSpace(AutomationExePath) == false)
            {
                FinalBuildPath = Path.GetFullPath(AutomationExePath).Replace(@"\Engine\Binaries\DotNET", @"\LocalBuilds\Engine").Replace(Path.GetFileName(AutomationExePath), "");
            }

            if (Directory.Exists(FinalBuildPath))
            {
                MessageBoxResult MessageResult = MessageBox.Show($"Looks like an Engine build is already available at {FinalBuildPath}. Would you like to skip compiling the Engine and start zipping the existing build?\n\nPress Yes to Skip Engine build and start zipping (if enabled).\nPress No to continue with Engine Build.\nPress Cancel to do nothing.", "Zip Binary Version", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
                switch (MessageResult)
                {
                case MessageBoxResult.Yes:
                    GameAnalyticsCSharp.AddDesignEvent("Build:EngineExists:FinishBuild");
                    // We don't want the system to shutdown since user is interacting.
                    bool?bOriginalShutdownState = bShutdownWindows.IsChecked;
                    bShutdownWindows.IsChecked = false;
                    OnBuildFinished(true);
                    bShutdownWindows.IsChecked = bOriginalShutdownState;
                    return;

                case MessageBoxResult.Cancel:
                    GameAnalyticsCSharp.AddDesignEvent("Build:EngineExists:Exit");
                    return;

                default:
                    GameAnalyticsCSharp.AddDesignEvent("Build:EngineExists:IgnoreAndContinue");
                    break;
                }
            }

            if (EngineVersionSelection.SelectedIndex == 0)
            {
                MessageBox.Show("Please select your Engine version to build. If you are unsure about the version number look into the following file:\n\n/Engine/Source/Runtime/Launch/Resources/Version.h\n\nAnd check ENGINE_MAJOR_VERSION and ENGINE_MINOR_VERSION.", "Select Engine Version.", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                return;
            }

            ChangeStatusLabel("Preparing to build...");

            if (postBuildSettings.ShouldSaveToZip() && postBuildSettings.DirectoryIsWritable() == false)
            {
                GameAnalyticsCSharp.AddDesignEvent("Build:ZipEnabled:InvalidSetting");
                MessageBox.Show(string.Format("You chose to save Engine build as a zip file but below directory is either not available or not writable.\n\n{0}", postBuildSettings.ZipPath.Text), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            if (CustomBuildXMLFile.Text != DEFAULT_BUILD_XML_FILE)
            {
                if (CustomBuildXMLFile.Text == string.Empty)
                {
                    GameAnalyticsCSharp.LogEvent("Empty Build XML.", GameAnalyticsSDK.Net.EGAErrorSeverity.Error);
                    ChangeStatusLabel("Error. Empty build xml file.");
                    MessageBox.Show(string.Format("Build XML cannot be empty.\n\nIf you don't have a custom build file, press \"Reset to default\" to use default InstalledEngineBuild.xml", CustomBuildXMLFile.Text), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                if (File.Exists(CustomBuildXMLFile.Text) == false)
                {
                    GameAnalyticsCSharp.LogEvent("BuildXML does not exist.", GameAnalyticsSDK.Net.EGAErrorSeverity.Error);
                    ChangeStatusLabel("Error. Build xml does not exist.");
                    MessageBox.Show(string.Format("Build XML {0} does not exist!", CustomBuildXMLFile.Text), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }

            if (SupportHTML5() == false && bWithHTML5.IsChecked == true)
            {
                GameAnalyticsCSharp.AddDesignEvent($"Build:HTML5:IncorrectEngine:{GetEngineName()}");
                bWithHTML5.IsChecked = false;
                MessageBox.Show("HTML5 support was removed from Unreal Engine 4.24 and higher. You had it enabled but since it is of no use, I disabled it.");
            }

            if (SupportConsoles() == false && (bWithSwitch.IsChecked == true || bWithPS4.IsChecked == true || bWithXboxOne.IsChecked == true))
            {
                GameAnalyticsCSharp.AddDesignEvent($"Build:Console:IncorrectEngine:{GetEngineName()}");
                bWithSwitch.IsChecked = bWithPS4.IsChecked = bWithXboxOne.IsChecked = false;
                MessageBox.Show("Console support was removed from Unreal Engine 4.25 and higher. You had it enabled but since it is of no use, I disabled it.");
            }

            if (MessageBox.Show("You are going to build a binary version of Unreal Engine 4. This is a long process and might take time to finish. Are you sure you want to continue? ", "Build Binary Version", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
            {
                if (bWithDDC.IsChecked == true)
                {
                    MessageBoxResult MessageResult = MessageBox.Show("Building Derived Data Cache (DDC) is one of the slowest aspect of the build. You can skip this step if you want to. Do you want to continue with DDC enabled?\n\nPress Yes to continue with build\nPress No to continue without DDC\nPress Cancel to stop build", "Warning", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning);

                    switch (MessageResult)
                    {
                    case MessageBoxResult.No:
                        bWithDDC.IsChecked = false;
                        GameAnalyticsCSharp.AddDesignEvent("Build:DDC:AutoDisabled");
                        break;

                    case MessageBoxResult.Cancel:
                        GameAnalyticsCSharp.AddDesignEvent("Build:DDC:Exit");
                        return;

                    default:
                        GameAnalyticsCSharp.AddDesignEvent("Build:DDC:IgnoreAndContinue");
                        break;
                    }
                }

                CompiledFiles = CompiledFilesTotal = 0;
                ProcessedFilesLabel.Content = "[Compiled: 0. Total: 0]";

                LogControl.ClearAllLogs();
                AddLogEntry(string.Format("Welcome to UE4 Binary Builder v{0}", PRODUCT_VERSION));
                BuildRocketUE.Content = "Stop Build";

                string CommandLineArgs = PrepareCommandline();

                ProcessStartInfo AutomationStartInfo = new ProcessStartInfo
                {
                    FileName               = AutomationExePath,
                    Arguments              = CommandLineArgs,
                    UseShellExecute        = false,
                    CreateNoWindow         = true,
                    RedirectStandardError  = true,
                    RedirectStandardOutput = true
                };

                DispatchTimer.Start();
                StopwatchTimer.Start();

                AutomationToolProcess                     = new Process();
                AutomationToolProcess.StartInfo           = AutomationStartInfo;
                AutomationToolProcess.EnableRaisingEvents = true;
                AutomationToolProcess.OutputDataReceived += new DataReceivedEventHandler(AutomationToolProcess_OutputDataReceived);
                AutomationToolProcess.ErrorDataReceived  += new DataReceivedEventHandler(AutomationToolProcess_ErrorDataReceived);
                AutomationToolProcess.Exited             += new EventHandler(AutomationToolProcess_Exited);
                AutomationToolProcess.Start();
                AutomationToolProcess.BeginErrorReadLine();
                AutomationToolProcess.BeginOutputReadLine();

                bIsBuilding = true;
                ChangeStatusLabel("Building...");
                GameAnalyticsCSharp.AddDesignEvent("Build:Started");
            }
        }