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 @@
>
-
+
-
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml.cs b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml.cs
index 8ec7a1f71c..030e9347b3 100644
--- a/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml.cs
+++ b/src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/WebProjectOptions/WebProjectOptionsPanel.xaml.cs
@@ -25,16 +25,32 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
CurrentProjectDebugData = new WebProjectDebugData();
Loaded += delegate(object sender, RoutedEventArgs e) {
+
+ if (!WebProjectService.IsIISInstalled) {
+ StatusLabel.Text = ResourceService.GetString("ICSharpCode.WepProjectOptionsPanel.IISNotFound");
+ return;
+ }
+
switch (CurrentProjectDebugData.WebServer)
{
case WebServer.IISExpress:
- UseIISExpress.IsChecked = true;
- UseIISExpress_Click(null, null);
+ if (WebProjectService.IISVersion == IISVersion.IISExpress) {
+ UseIISExpress.IsChecked = true;
+ IISExpressGroup.IsEnabled = true;
+ CreateVirtualDirectoryButton.IsEnabled = true;
+ PortTextBox.Text = CurrentProjectDebugData.Port;
+ }
break;
case WebServer.IIS:
- UseLocalIIS.IsChecked = true;
- ProjectUrl.Text = CurrentProjectDebugData.ProjectUrl ?? string.Empty;
- UseLocalIIS_Click(null, null);
+ if (WebProjectService.IISVersion == IISVersion.IIS5 ||
+ WebProjectService.IISVersion == IISVersion.IIS6 ||
+ WebProjectService.IISVersion == IISVersion.IIS7 ||
+ WebProjectService.IISVersion == IISVersion.IIS_Future) {
+ UseLocalIIS.IsChecked = true;
+ LocalIISGroup.IsEnabled = true;
+ CreateVirtualDirectoryButton.IsEnabled = true;
+ ProjectUrl.Text = CurrentProjectDebugData.ProjectUrl ?? string.Empty;
+ }
break;
default:
// do nothing
@@ -63,7 +79,7 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
else
data = new WebProjectOptions();
- WebProjectsOptions.Instance.SetWebProjectOptions(ProjectService.CurrentProject.Name, data);
+ WebProjectsOptions.Instance.SetWebProjectOptions(ProjectService.CurrentProject.Name, data);
}
}
@@ -83,12 +99,20 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
{
WebProjectDebugData data = new WebProjectDebugData();
data.WebServer = WebServer.IISExpress;
+ data.Port = PortTextBox.Text;
+ data.ProjectUrl = string.Format(@"http://localhost:{0}/" + ProjectService.CurrentProject.Name, PortTextBox.Text);
+ bool isIISExpressInstalled = WebProjectService.IISVersion == IISVersion.IISExpress;
- if (ProjectService.CurrentProject is CompilableProject) {
- ((CompilableProject)ProjectService.CurrentProject).StartAction = StartAction.Program;
- parentPanel.SetStartAction(StartAction.Program);
+ if (!isIISExpressInstalled) {
+ UseIISExpress.IsChecked = false;
+ data.WebServer = WebServer.None;
+ StatusLabel.Text = ResourceService.GetString("ICSharpCode.WepProjectOptionsPanel.IISNotFound");
+ data.ProjectUrl = string.Empty;
}
+ else
+ StatusLabel.Text = string.Empty;
+ IISExpressGroup.IsEnabled = CreateVirtualDirectoryButton.IsEnabled = isIISExpressInstalled;
LocalIISGroup.IsEnabled = false;
CurrentProjectDebugData = data;
}
@@ -97,11 +121,16 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
{
WebProjectDebugData data = new WebProjectDebugData();
data.WebServer = WebServer.IIS;
+ data.Port = string.Empty;
+ bool isIISInstalled = WebProjectService.IISVersion == IISVersion.IIS5 ||
+ WebProjectService.IISVersion == IISVersion.IIS6 ||
+ WebProjectService.IISVersion == IISVersion.IIS7;
- if (!WebProjectService.IsIISInstalled) {
+ if (!isIISInstalled) {
StatusLabel.Text = ResourceService.GetString("ICSharpCode.WepProjectOptionsPanel.IISNotFound");
ProjectUrl.Text = string.Empty;
data.WebServer = WebServer.None;
+ UseLocalIIS.IsChecked = false;
}
else {
StatusLabel.Text = string.Empty;
@@ -109,15 +138,8 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
}
data.ProjectUrl = ProjectUrl.Text;
- CreateVirtualDirectoryButton.IsEnabled = WebProjectService.IsIISInstalled;
- ProjectUrl.IsEnabled = WebProjectService.IsIISInstalled;
-
- if (ProjectService.CurrentProject is CompilableProject) {
- ((CompilableProject)ProjectService.CurrentProject).StartAction = StartAction.Project;
- parentPanel.SetStartAction(StartAction.Project);
- }
-
- LocalIISGroup.IsEnabled = true;
+ LocalIISGroup.IsEnabled = CreateVirtualDirectoryButton.IsEnabled = isIISInstalled;
+ IISExpressGroup.IsEnabled = false;
CurrentProjectDebugData = data;
}
@@ -128,5 +150,37 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
data.ProjectUrl = ProjectUrl.Text;
CurrentProjectDebugData = data;
}
+
+ void ClearWebServerButton_Click(object sender, RoutedEventArgs e)
+ {
+ UseIISExpress.IsChecked = false;
+ UseLocalIIS.IsChecked = false;
+ CreateVirtualDirectoryButton.IsEnabled = false;
+ ProjectUrl.Text = string.Empty;
+ LocalIISGroup.IsEnabled = false;
+ IISExpressGroup.IsEnabled = false;
+
+ WebProjectDebugData data = new WebProjectDebugData();
+ data.WebServer = WebServer.None;
+ data.ProjectUrl = string.Empty;
+
+ CurrentProjectDebugData = data;
+ }
+
+ bool AreAllValidNumericChars(string str)
+ {
+ foreach(char c in str)
+ {
+ if(!Char.IsNumber(c)) return false;
+ }
+
+ return true;
+ }
+
+ void PortTextBox_PreviewTextInput(object sender, System.Windows.Input.TextCompositionEventArgs e)
+ {
+ e.Handled = !AreAllValidNumericChars(e.Text);
+ base.OnPreviewTextInput(e);
+ }
}
}
\ No newline at end of file
diff --git a/src/Main/Base/Project/Src/Services/WebProjectService/WebProjectService.cs b/src/Main/Base/Project/Src/Services/WebProjectService/WebProjectService.cs
index 79990f07c9..c8c1e238fd 100644
--- a/src/Main/Base/Project/Src/Services/WebProjectService/WebProjectService.cs
+++ b/src/Main/Base/Project/Src/Services/WebProjectService/WebProjectService.cs
@@ -3,6 +3,9 @@
using System;
using System.EnterpriseServices.Internal;
+using System.IO;
+using System.Reflection;
+
using ICSharpCode.Core;
using Microsoft.Win32;
@@ -10,6 +13,7 @@ namespace ICSharpCode.SharpDevelop.Project
{
public enum IISVersion
{
+ None = 0,
IIS5 = 5,
IIS6,
IIS7,
@@ -42,10 +46,12 @@ namespace ICSharpCode.SharpDevelop.Project
const string FRAMEWORK32 = @"Framework\";
const string FRAMEWORK64 = @"Framework64\";
- public const string IIS_EXPRESS_PROCESS_NAME = "iisexpress";
+ public const string IIS_EXPRESS_PROCESS_NAME = "iisexpress";
public const string IIS_5_PROCESS_NAME = "aspnet_wp";
public const string IIS_NEW_PROCESS_NAME = "w3wp";
+ public const string IIS_EXPRESS_PROCESS_LOCATION = @"C:\Program Files\IIS Express\iisexpress.exe";
+
///
/// Gets the IIS worker process name.
///
@@ -149,12 +155,18 @@ namespace ICSharpCode.SharpDevelop.Project
RegistryValueKind.DWord,
out regValue);
- return (IISVersion)regValue;
+ if (regValue > 4)
+ return (IISVersion)regValue;
+
+ if (File.Exists(WebProjectService.IIS_EXPRESS_PROCESS_LOCATION))
+ return IISVersion.IISExpress;
+
+ return IISVersion.None;
}
}
///
- /// Creates a virtual directory in IIS.
+ /// Creates a virtual directory in local IIS or IIS Express.
///
/// Virtual directory name.
/// Physical path.
@@ -179,21 +191,40 @@ namespace ICSharpCode.SharpDevelop.Project
break;
default:
- using (var manager = new Microsoft.Web.Administration.ServerManager())
- {
- if (manager.Sites[DEFAULT_WEB_SITE] != null) {
- string name = "/" + virtualDirectoryName;
- if (manager.Sites[DEFAULT_WEB_SITE].Applications[name] == null) {
- manager.Sites[DEFAULT_WEB_SITE].Applications.Add(name, physicalDirectoryPath);
- manager.CommitChanges();
- error = string.Empty;
- } else {
- error = ResourceService.GetString("ICSharpCode.WepProjectOptionsPanel.ApplicationExists");
- }
+ // TODO: find a better way to create IIS 7 applications without Microsoft.Web.Administration.ServerManager
+ string name = "/" + virtualDirectoryName;
+ // load from GAC - IIS7 is installed
+ Assembly webAdministrationAssembly;
+ try {
+ // iis 7
+ webAdministrationAssembly = Assembly.Load("Microsoft.Web.Administration, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
+ }
+ catch {
+ // iis express
+ webAdministrationAssembly = Assembly.Load("Microsoft.Web.Administration, Version=7.9.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35");
+ }
+
+ // use dynamic because classic reflection is way TOO ugly
+ dynamic manager = webAdministrationAssembly.CreateInstance("Microsoft.Web.Administration.ServerManager");
+
+ if (manager.Sites[DEFAULT_WEB_SITE] != null) {
+ if (manager.Sites[DEFAULT_WEB_SITE].Applications[name] == null) {
+ manager.Sites[DEFAULT_WEB_SITE].Applications.Add(name, physicalDirectoryPath);
+ manager.CommitChanges();
+ error = string.Empty;
+ } else {
+ error = ResourceService.GetString("ICSharpCode.WepProjectOptionsPanel.ApplicationExists");
+ }
+ } else {
+ if (manager.Sites[0].Applications[name] == null) {
+ manager.Sites[0].Applications.Add(name, physicalDirectoryPath);
+ manager.CommitChanges();
+ error = string.Empty;
+ } else {
+ error = ResourceService.GetString("ICSharpCode.WepProjectOptionsPanel.ApplicationExists");
}
- else
- error = ResourceService.GetString("ICSharpCode.WepProjectOptionsPanel.MultipleIISServers");
}
+ manager.Dispose();
break;
}