From f51a45646daee101b58c9524c701a3f80d48402c Mon Sep 17 00:00:00 2001 From: Eusebiu Marcu Date: Tue, 11 Jan 2011 04:01:40 +0200 Subject: [PATCH] support IIS Express --- data/resources/StringResources.resx | 14 ++- .../Debugger.AddIn/Service/WindowsDebugger.cs | 39 ++++---- .../Project/ICSharpCode.SharpDevelop.csproj | 2 +- .../ProjectOptions/DebugOptions.cs | 10 +- .../WebProjectOptions/WebProjectOptions.cs | 3 + .../WebProjectOptionsPanel.xaml | 54 +++++++---- .../WebProjectOptionsPanel.xaml.cs | 92 +++++++++++++++---- .../WebProjectService/WebProjectService.cs | 63 +++++++++---- 8 files changed, 200 insertions(+), 77 deletions(-) diff --git a/data/resources/StringResources.resx b/data/resources/StringResources.resx index 23747d0d46..27a89c7e26 100644 --- a/data/resources/StringResources.resx +++ b/data/resources/StringResources.resx @@ -3756,13 +3756,13 @@ You can also choose to store the setting in the .user-file instead of the projec Web Server - Create virtual directory + Create application/virtual directory - IIS was not found + Local IIS or IIS Express was not found. - Virtual directory was created + Application/virtual directory was created. Project Url: @@ -3771,7 +3771,7 @@ You can also choose to store the setting in the .user-file instead of the projec Use local IIS Web server - Use local IIS Express Web server + Use IIS Express Web server There's no Project Url specified or external program. Check the web server at Project Properties -> Debug tab. @@ -3785,6 +3785,12 @@ You can also choose to store the setting in the .user-file instead of the projec Debugger was unable to attach to process. + + Disable web server options + + + Server port: + There is no startup project to debug. diff --git a/src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs b/src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs index d90931b798..037d19051b 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs @@ -139,7 +139,7 @@ namespace ICSharpCode.SharpDevelop.Services if (!ServiceInitialized) { InitializeService(); } - + if (FileUtility.IsUrl(processStartInfo.FileName)) { var project = ProjectService.OpenSolution.Preferences.StartupProject as CompilableProject; @@ -156,33 +156,30 @@ namespace ICSharpCode.SharpDevelop.Services if (debugData.Data.WebServer != WebServer.None) { - // try attach to IIS WP - var processes = System.Diagnostics.Process.GetProcesses(); - string processName = WebProjectService.WorkerProcessName; - if (debugData.Data.WebServer == WebServer.IISExpress) - processName = WebProjectService.IIS_EXPRESS_PROCESS_NAME; + System.Diagnostics.Process defaultAppProcess = null; - System.Diagnostics.Process localProcess = null; + string processName = WebProjectService.WorkerProcessName; - // try find the worker process - int index = processes.FindIndex( - p => p.ProcessName.IndexOf(processName, StringComparison.OrdinalIgnoreCase) == 0); + // try find the worker process directly or using the process monitor callback + var processes = System.Diagnostics.Process.GetProcesses(); + int index = processes.FindIndex(p => p.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase)); if (index > -1){ Attach(processes[index]); } else { this.monitor = new ProcessMonitor(processName); this.monitor.ProcessCreated += delegate { + if (attached) + return; processes = System.Diagnostics.Process.GetProcesses(); - index = processes.FindIndex( - p => p.ProcessName.IndexOf(processName, StringComparison.OrdinalIgnoreCase) == 0); - Attach(processes[index]); + index = processes.FindIndex(p => p.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase)); + WorkbenchSingleton.SafeThreadCall((Action)(() => Attach(processes[index]))); if (!attached) { if(debugData.Data.WebServer == WebServer.IIS) { string format = ResourceService.GetString("ICSharpCode.WepProjectOptionsPanel.NoIISWP"); MessageService.ShowMessage(string.Format(format, processName)); } else { - Attach(localProcess); + WorkbenchSingleton.SafeThreadCall((Action)(() => Attach(defaultAppProcess))); if (!attached) { MessageService.ShowMessage(ResourceService.GetString("ICSharpCode.WepProjectOptionsPanel.UnableToAttach")); } @@ -192,15 +189,23 @@ namespace ICSharpCode.SharpDevelop.Services this.monitor.Start(); } + if (debugData.Data.WebServer == WebServer.IISExpress) { + // start IIS express and attach to it + if (WebProjectService.IISVersion == IISVersion.IISExpress) + System.Diagnostics.Process.Start(WebProjectService.IIS_EXPRESS_PROCESS_LOCATION); + else + MessageService.ShowError("${res:ICSharpCode.WepProjectOptionsPanel.NoProjectUrlOrProgramAction}"); + } + // start default application(e.g. browser) if (project.StartAction == StartAction.StartURL) - localProcess = System.Diagnostics.Process.Start(processStartInfo.FileName); + defaultAppProcess = System.Diagnostics.Process.Start(processStartInfo.FileName); else { if (!string.IsNullOrEmpty(debugData.Data.ProjectUrl) && debugData.Data.WebServer == WebServer.IIS) - localProcess = System.Diagnostics.Process.Start(debugData.Data.ProjectUrl); + defaultAppProcess = System.Diagnostics.Process.Start(debugData.Data.ProjectUrl); else { if (debugData.Data.WebServer == WebServer.IISExpress) - localProcess = System.Diagnostics.Process.Start(debugData.Data.ProjectUrl); + defaultAppProcess = System.Diagnostics.Process.Start(debugData.Data.ProjectUrl); } } } diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index a919c46027..5c438acc2e 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -44,7 +44,7 @@ TRACE;PUBLICINTERPROCESS - + ..\..\..\Libraries\Mono.Cecil\Mono.Cecil.dll False diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/DebugOptions.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/DebugOptions.cs index 7d4d0af151..e4031b03af 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/DebugOptions.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/DebugOptions.cs @@ -61,7 +61,7 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels if (isWebProject) { ElementHost host = new ElementHost(); host.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; - host.Height = 150; + host.Height = 175; host.Width = 550; host.Top = 240; host.Left = 8; @@ -95,5 +95,13 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels UpdateEnabledStates(null, EventArgs.Empty); } + + public void SetExternalProgram(string externalProgram) + { + if (externalProgram == null) + return; + + Get("startExternalProgram").Text = externalProgram; + } } } diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptions.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptions.cs index 3a89ae5cac..9af85e54c7 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptions.cs +++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptions.cs @@ -64,5 +64,8 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels [DefaultValue(WebServer.None)] public WebServer WebServer { get; set; } + + [DefaultValue("8080")] + public string Port { get; set; } } } diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml index 128c54e8d3..f8154a4a4e 100644 --- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml +++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml @@ -4,32 +4,42 @@ > - + - + + + + + + + + + - + - - -