protected override void DoExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector config) { //check XSP is available var configuration = (AspNetAppProjectConfiguration)GetConfiguration(config); var cmd = CreateExecutionCommand(config, configuration); IConsole console = null; var operationMonitor = new AggregatedOperationMonitor(monitor); try { if (configuration.ExternalConsole) { console = context.ExternalConsoleFactory.CreateConsole(!configuration.PauseConsoleOutput); } else { console = context.ConsoleFactory.CreateConsole(!configuration.PauseConsoleOutput); } string url = String.Format("http://{0}:{1}", this.XspParameters.Address, this.XspParameters.Port); bool isXsp = true; //FIXME: fix this when it might not be true if (isXsp) { console = new XspBrowserLauncherConsole(console, delegate { BrowserLauncher.LaunchDefaultBrowser(url); }); } monitor.Log.WriteLine("Running web server..."); var op = context.ExecutionHandler.Execute(cmd, console); operationMonitor.AddOperation(op); //handles cancellation if (!isXsp) { BrowserLauncher.LaunchDefaultBrowser(url); } op.WaitForCompleted(); monitor.Log.WriteLine("The web server exited with code: {0}", op.ExitCode); } catch (Exception ex) { monitor.ReportError("Could not launch web server.", ex); } finally { operationMonitor.Dispose(); if (console != null) { console.Dispose(); } } }
protected override void DoExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector config) { //check XSP is available var configuration = (AspNetAppProjectConfiguration)GetConfiguration(config); var cmd = CreateExecutionCommand(config, configuration); IConsole console = null; var operationMonitor = new AggregatedOperationMonitor(monitor); bool isXsp = true; //FIXME: fix this when it might not be true - should delegate to the ExecutionHandler try { //HACK: check XSP exists first, because error UX is cleaner w/o displaying a blank console pad. if (isXsp) { try { AspNetExecutionHandler.GetXspPath((AspNetExecutionCommand)cmd); } catch (UserException ex) { MessageService.ShowError( GettextCatalog.GetString("Could not launch ASP.NET web server"), ex.Message); throw; } } if (configuration.ExternalConsole) { console = context.ExternalConsoleFactory.CreateConsole(!configuration.PauseConsoleOutput); } else { console = context.ConsoleFactory.CreateConsole(!configuration.PauseConsoleOutput); } string url = String.Format("http://{0}:{1}", this.XspParameters.Address, this.XspParameters.Port); if (isXsp) { console = new XspBrowserLauncherConsole(console, delegate { BrowserLauncher.LaunchDefaultBrowser(url); }); } monitor.Log.WriteLine("Running web server..."); var op = context.ExecutionHandler.Execute(cmd, console); operationMonitor.AddOperation(op); //handles cancellation if (!isXsp) { BrowserLauncher.LaunchDefaultBrowser(url); } op.WaitForCompleted(); monitor.Log.WriteLine("The web server exited with code: {0}", op.ExitCode); } catch (Exception ex) { if (!(ex is UserException)) { LoggingService.LogError("Could not launch ASP.NET web server.", ex); } monitor.ReportError("Could not launch web server.", ex); } finally { operationMonitor.Dispose(); if (console != null) { console.Dispose(); } } }