public override DebuggerStartInfo CreateDebuggerStartInfo(ExecutionCommand command) { var cmd = (AspNetExecutionCommand)command; var evars = new Dictionary <string, string>(cmd.EnvironmentVariables); var runtime = (MonoTargetRuntime)cmd.TargetRuntime; foreach (var v in runtime.EnvironmentVariables) { if (!evars.ContainsKey(v.Key)) { evars.Add(v.Key, v.Value); } } //HACK: work around Mono trying to create registry in non-writable location if (cmd.TargetRuntime is MonoTargetRuntime && !Platform.IsWindows) { evars ["MONO_REGISTRY_PATH"] = UserProfile.Current.TempDir.Combine("aspnet-registry"); } var startInfo = new SoftDebuggerStartInfo(runtime.Prefix, evars) { WorkingDirectory = cmd.BaseDirectory, Arguments = cmd.XspParameters.GetXspParameters().Trim(), }; var xspName = AspNetExecutionHandler.GetXspName(cmd); FilePath fxDir = GetFxDir(runtime, cmd.ClrVersion); FilePath xspPath = fxDir.Combine(xspName).ChangeExtension(".exe"); //no idea why xsp is sometimes relocated to a "winhack" dir on Windows if (MonoDevelop.Core.Platform.IsWindows && !File.Exists(xspPath)) { var winhack = fxDir.Combine("winhack"); if (Directory.Exists(winhack)) { xspPath = winhack.Combine(xspName).ChangeExtension(".exe"); } } if (!File.Exists(xspPath)) { throw new UserException(GettextCatalog.GetString( "The \"{0}\" web server cannot be started. Please ensure that it is installed.", xspName), null); } startInfo.Command = xspPath; SoftDebuggerEngine.SetUserAssemblyNames(startInfo, cmd.UserAssemblyPaths); return(startInfo); }
public DebuggerStartInfo CreateDebuggerStartInfo(ExecutionCommand command) { DotNetExecutionCommand cmd = command as DotNetExecutionCommand; if (cmd != null) { DebuggerStartInfo startInfo = new DebuggerStartInfo(); startInfo.Command = cmd.Command; startInfo.Arguments = cmd.Arguments; startInfo.WorkingDirectory = cmd.WorkingDirectory; if (cmd.EnvironmentVariables.Count > 0) { foreach (KeyValuePair <string, string> val in cmd.EnvironmentVariables) { startInfo.EnvironmentVariables[val.Key] = val.Value; } } return(startInfo); } #if ASPNET var acmd = command as AspNetExecutionCommand; if (acmd != null) { DebuggerStartInfo startInfo = new DebuggerStartInfo(); string xspName = AspNetExecutionHandler.GetXspName(acmd); string xspPath = acmd.TargetRuntime.GetToolPath(acmd.TargetFramework, xspName); if (!File.Exists(xspPath)) { throw new UserException(string.Format("The \"{0}\" web server cannot be started. Please ensure that it is installed.", xspName), null); } startInfo.Command = xspPath; startInfo.Arguments = acmd.XspParameters.GetXspParameters() + " --nonstop"; startInfo.WorkingDirectory = acmd.BaseDirectory; // Set DEVPATH when running on Windows (notice that this has no effect unless // <developmentMode developerInstallation="true" /> is set in xsp2.exe.config startInfo.EnvironmentVariables["DEVPATH"] = Path.GetDirectoryName(xspPath); return(startInfo); } #endif throw new NotSupportedException(); }
public DebuggerStartInfo CreateDebuggerStartInfo(ExecutionCommand command) { var cmd = (AspNetExecutionCommand)command; var runtime = (MonoTargetRuntime)cmd.TargetRuntime; var startInfo = new SoftDebuggerStartInfo(runtime.Prefix, runtime.EnvironmentVariables) { WorkingDirectory = cmd.BaseDirectory, Arguments = cmd.XspParameters.GetXspParameters().Trim(), }; var xspName = AspNetExecutionHandler.GetXspName(cmd); FilePath fxDir = GetFxDir(runtime, cmd.ClrVersion); FilePath xspPath = fxDir.Combine(xspName).ChangeExtension(".exe"); //no idea why xsp is sometimes relocated to a "winhack" dir on Windows if (MonoDevelop.Core.Platform.IsWindows && !File.Exists(xspPath)) { var winhack = fxDir.Combine("winhack"); if (Directory.Exists(winhack)) { xspPath = winhack.Combine(xspName).ChangeExtension(".exe"); } } if (!File.Exists(xspPath)) { throw new UserException(GettextCatalog.GetString( "The \"{0}\" web server cannot be started. Please ensure that it is installed.", xspName), null); } startInfo.Command = xspPath; SoftDebuggerEngine.SetUserAssemblyNames(startInfo, cmd.UserAssemblyPaths); return(startInfo); }
protected async override Task OnExecute(ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration) { //check XSP is available var cfg = GetConfiguration(configuration); var cmd = CreateExecutionCommand(configuration, cfg); var browserExcTarget = context.ExecutionTarget as BrowserExecutionTarget; OperationConsole console = null; 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; } } console = context.ConsoleFactory.CreateConsole(monitor.CancellationToken); // The running Port value is now captured in the XspBrowserLauncherConsole object string url = String.Format("http://{0}", XspParameters.Address); if (isXsp) { console = new XspBrowserLauncherConsole(console, delegate(string port) { if (browserExcTarget != null) { browserExcTarget.DesktopApp.Launch(String.Format("{0}:{1}", url, port)); } else { BrowserLauncher.LaunchDefaultBrowser(String.Format("{0}:{1}", url, port)); } }); } monitor.Log.WriteLine(GettextCatalog.GetString("Running web server...")); var op = context.ExecutionHandler.Execute(cmd, console); if (!isXsp) { if (browserExcTarget != null) { browserExcTarget.DesktopApp.Launch(url); } else { BrowserLauncher.LaunchDefaultBrowser(url); } } using (monitor.CancellationToken.Register(op.Cancel)) await op.Task; monitor.Log.WriteLine(GettextCatalog.GetString("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(GettextCatalog.GetString("Could not launch web server."), ex); } finally { if (console != null) { console.Dispose(); } } }