internal static ExitType Execute() { switch (Environment.GetEnvironmentVariable("MSBUILDDEBUGONSTART")) { #if FEATURE_DEBUG_LAUNCH case "1": Debugger.Launch(); break; #endif case "2": // Sometimes easier to attach rather than deal with JIT prompt Process currentProcess = Process.GetCurrentProcess(); Console.WriteLine($"Waiting for debugger to attach ({currentProcess.MainModule.FileName} PID {currentProcess.Id}). Press enter to continue..."); Console.ReadLine(); break; } bool restart = false; do { OutOfProcTaskHostNode oopTaskHostNode = new OutOfProcTaskHostNode(); Exception taskHostShutDownException = null; NodeEngineShutdownReason taskHostShutDownReason = oopTaskHostNode.Run(out taskHostShutDownException); if (taskHostShutDownException != null) { return(ExitType.TaskHostNodeFailed); } switch (taskHostShutDownReason) { case NodeEngineShutdownReason.BuildComplete: return(ExitType.Success); case NodeEngineShutdownReason.BuildCompleteReuse: restart = true; break; default: return(ExitType.TaskHostNodeFailed); } }while (restart); // Should not happen ErrorUtilities.ThrowInternalErrorUnreachable(); return(ExitType.Unexpected); }
/// <summary> /// Orchestrates the execution of the application. /// Also responsible for top-level error handling. /// </summary> /// <returns> /// A value of Success if the bootstrapping succeeds /// </returns> internal static ExitType Execute() { #if FEATURE_DEBUG_LAUNCH // Provide Hook for debugger if (Environment.GetEnvironmentVariable("MSBUILDDEBUGONSTART") == "1") { Debugger.Launch(); } #endif bool restart = false; do { OutOfProcTaskHostNode oopTaskHostNode = new OutOfProcTaskHostNode(); Exception taskHostShutDownException = null; NodeEngineShutdownReason taskHostShutDownReason = oopTaskHostNode.Run(out taskHostShutDownException); if (taskHostShutDownException != null) { return(ExitType.TaskHostNodeFailed); } switch (taskHostShutDownReason) { case NodeEngineShutdownReason.BuildComplete: return(ExitType.Success); case NodeEngineShutdownReason.BuildCompleteReuse: restart = true; break; default: return(ExitType.TaskHostNodeFailed); } }while (restart); // Should not happen ErrorUtilities.ThrowInternalErrorUnreachable(); return(ExitType.Unexpected); }
/// <summary> /// Uses the input from thinNodeMode switch to start a local node server /// </summary> /// <param name="commandLineSwitches"></param> private static void StartLocalNode(CommandLineSwitches commandLineSwitches) { string[] input = commandLineSwitches[CommandLineSwitches.ParameterizedSwitch.NodeMode]; int nodeModeNumber = 0; if (input.Length > 0) { try { nodeModeNumber = int.Parse(input[0], CultureInfo.InvariantCulture); } catch (FormatException ex) { CommandLineSwitchException.Throw("InvalidNodeNumberValue", input[0], ex.Message); } catch (OverflowException ex) { CommandLineSwitchException.Throw("InvalidNodeNumberValue", input[0], ex.Message); } CommandLineSwitchException.VerifyThrow(nodeModeNumber >= 0, "InvalidNodeNumberValueIsNegative", input[0]); } #if !STANDALONEBUILD if (!commandLineSwitches[CommandLineSwitches.ParameterlessSwitch.OldOM]) #endif { bool restart = true; while (restart) { Exception nodeException = null; NodeEngineShutdownReason shutdownReason = NodeEngineShutdownReason.Error; // normal OOP node case if (nodeModeNumber == 1) { OutOfProcNode node = new OutOfProcNode(); shutdownReason = node.Run(ProcessNodeReuseSwitch(commandLineSwitches[CommandLineSwitches.ParameterizedSwitch.NodeReuse]), out nodeException); FileUtilities.ClearCacheDirectory(); } else if (nodeModeNumber == 2) { OutOfProcTaskHostNode node = new OutOfProcTaskHostNode(); shutdownReason = node.Run(out nodeException); } else { CommandLineSwitchException.Throw("InvalidNodeNumberValue", input[0]); } if (shutdownReason == NodeEngineShutdownReason.Error) { Debug.WriteLine("An error has happened, throwing an exception"); throw nodeException; } if (shutdownReason != NodeEngineShutdownReason.BuildCompleteReuse) { restart = false; } } } #if !STANDALONEBUILD else { StartLocalNodeOldOM(nodeModeNumber); } #endif }
/// <summary> /// Orchestrates the execution of the application. /// Also responsible for top-level error handling. /// </summary> /// <returns> /// A value of Success if the bootstrapping succeeds /// </returns> internal static ExitType Execute() { // Provide Hook for debugger if (Environment.GetEnvironmentVariable("MSBUILDDEBUGONSTART") == "1") { Debugger.Launch(); } bool restart = false; do { OutOfProcTaskHostNode oopTaskHostNode = new OutOfProcTaskHostNode(); Exception taskHostShutDownException = null; NodeEngineShutdownReason taskHostShutDownReason = oopTaskHostNode.Run(out taskHostShutDownException); if (taskHostShutDownException != null) { return ExitType.TaskHostNodeFailed; } switch (taskHostShutDownReason) { case NodeEngineShutdownReason.BuildComplete: return ExitType.Success; case NodeEngineShutdownReason.BuildCompleteReuse: restart = true; break; default: return ExitType.TaskHostNodeFailed; } } while (restart); // Should not happen ErrorUtilities.ThrowInternalErrorUnreachable(); return ExitType.Unexpected; }