diff --git a/data/resources/StringResources.resx b/data/resources/StringResources.resx index 605c4c2af4..10f7e090fd 100644 --- a/data/resources/StringResources.resx +++ b/data/resources/StringResources.resx @@ -5167,7 +5167,7 @@ Goto 'Options->Visual Style' and change the current language ambience.ASP.NET/IIS (Express) worker process ({0}) was not found. - There's no Project Url specified or external program. Check the web server at Project Properties -> Debug tab. + There's no Project Url specified or external program. Check the web server at Project Properties - Debug tab. Server port: @@ -6550,6 +6550,12 @@ Removed the end part of the original message ", reason '${Message}'" since this Set as St&artUp Project + + View in browser + + + The project is not a web project. + New Folder diff --git a/data/resources/image/BitmapResources/BitmapResources-data/Icons.22x22.Browser.png b/data/resources/image/BitmapResources/BitmapResources-data/Icons.22x22.Browser.png new file mode 100644 index 0000000000..e4c46adf4b Binary files /dev/null and b/data/resources/image/BitmapResources/BitmapResources-data/Icons.22x22.Browser.png differ diff --git a/data/resources/image/BitmapResources/BitmapResources.res b/data/resources/image/BitmapResources/BitmapResources.res index fbe4429e98..dbbb6c9963 100644 --- a/data/resources/image/BitmapResources/BitmapResources.res +++ b/data/resources/image/BitmapResources/BitmapResources.res @@ -60,6 +60,7 @@ Icons.16x16.ClosedReferenceFolder = ProjectBrowserIcons\GhostFol Icons.16x16.OpenResourceFolder = ProjectBrowserIcons\PropertyFolder.Open.png Icons.16x16.ClosedResourceFolder = ProjectBrowserIcons\PropertyFolder.Closed.png +Icons.22x22.Browser = BitmapResources-data\Icons.22x22.Browser.png Icons.16x16.ArrowLeftRight = BitmapResources-data\Icons.16x16.ArrowLeftRight.png Icons.16x16.ArrowDown = BitmapResources-data\Icons.16x16.ArrowDown.png diff --git a/src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs b/src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs index 27d5dc29c0..94a66521b6 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Service/WindowsDebugger.cs @@ -161,25 +161,21 @@ namespace ICSharpCode.SharpDevelop.Services if (index > -1){ Attach(processes[index]); } else { - try { - this.monitor = new ProcessMonitor(processName); - this.monitor.ProcessCreated += delegate { - WorkbenchSingleton.SafeThreadCall((Action)(() => OnProcessCreated(defaultAppProcess, options))); - }; - this.monitor.Start(); - } - catch (System.Exception ex) { - LoggingService.ErrorFormatted("Process Monitor exception: {0}", ex.Message); - } - } - - if (options.Data.WebServer == WebServer.IISExpress) { - // start IIS express and attach to it - if (WebProjectService.IISVersion == IISVersion.IISExpress) { - System.Diagnostics.Process.Start(WebProjectService.IISExpressProcessLocation); - } else { - MessageService.ShowError("${res:ICSharpCode.WepProjectOptionsPanel.NoProjectUrlOrProgramAction}"); - return; + this.monitor = new ProcessMonitor(processName); + this.monitor.ProcessCreated += delegate { + WorkbenchSingleton.SafeThreadCall((Action)(() => OnProcessCreated(defaultAppProcess, options))); + }; + this.monitor.Start(); + + if (options.Data.WebServer == WebServer.IISExpress) { + // start IIS express and attach to it + if (WebProjectService.IISVersion == IISVersion.IISExpress) { + System.Diagnostics.Process.Start(WebProjectService.IISExpressProcessLocation); + } else { + DisposeProcessMonitor(); + MessageService.ShowError("${res:ICSharpCode.WepProjectOptionsPanel.NoProjectUrlOrProgramAction}"); + return; + } } } @@ -190,6 +186,7 @@ namespace ICSharpCode.SharpDevelop.Services defaultAppProcess = System.Diagnostics.Process.Start(options.Data.ProjectUrl); } else { MessageService.ShowError("${res:ICSharpCode.WepProjectOptionsPanel.NoProjectUrlOrProgramAction}"); + DisposeProcessMonitor(); return; } break; @@ -205,6 +202,7 @@ namespace ICSharpCode.SharpDevelop.Services defaultAppProcess = System.Diagnostics.Process.Start(url); } else { MessageService.ShowError("${res:ICSharpCode.WepProjectOptionsPanel.NoProjectUrlOrProgramAction}"); + DisposeProcessMonitor(); return; } } @@ -216,6 +214,7 @@ namespace ICSharpCode.SharpDevelop.Services string err = "Error: " + ex.Message; MessageService.ShowError(err); LoggingService.Error(err); + DisposeProcessMonitor(); return; } } else { @@ -268,7 +267,7 @@ namespace ICSharpCode.SharpDevelop.Services } } } - + public void ShowAttachDialog() { using (AttachToProcessForm attachForm = new AttachToProcessForm()) { @@ -409,11 +408,7 @@ namespace ICSharpCode.SharpDevelop.Services debuggedProcess.Terminate(); } - if (monitor != null) { - monitor.Stop(); - monitor.Dispose(); - monitor = null; - } + DisposeProcessMonitor(); } bool CheckWebProjectStartInfo() @@ -449,6 +444,8 @@ namespace ICSharpCode.SharpDevelop.Services string processName = WebProjectService.WorkerProcessName; var processes = System.Diagnostics.Process.GetProcesses(); int index = processes.FindIndex(p => p.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase)); + if (index == -1) + return; Attach(processes[index]); if (!attached) { @@ -464,6 +461,15 @@ namespace ICSharpCode.SharpDevelop.Services } } + void DisposeProcessMonitor() + { + if (monitor != null) { + monitor.Stop(); + monitor.Dispose(); + monitor = null; + } + } + // ExecutionControl: public void Break() @@ -688,7 +694,7 @@ namespace ICSharpCode.SharpDevelop.Services } catch (System.Exception ex) { LoggingService.Error("Error on GetTooltipControl: " + ex.Message); return null; - } + } } public ITreeNode GetNode(string variable, string currentImageName = null) diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin b/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin index 102252206b..6e4640abe9 100755 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.addin @@ -31,6 +31,7 @@ + @@ -457,9 +458,26 @@ label = "${res:ProjectComponent.ContextMenu.IncludeFileInProject}" class = "ICSharpCode.SharpDevelop.Project.Commands.IncludeFileInProject"/> - + + + + + + + + + + + + + + + + @@ -279,6 +280,7 @@ + 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 f7c41a1b43..3292b3e813 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 @@ -140,10 +140,9 @@ namespace ICSharpCode.SharpDevelop.Gui.OptionPanels ProjectUrl.Text = string.Empty; data.WebServer = WebServer.None; UseLocalIIS.IsChecked = false; - } - else { + } else { StatusLabel.Text = string.Empty; - ProjectUrl.Text = @"http://localhost/" + ProjectService.CurrentProject.Name; + ProjectUrl.Text = string.Format("{0}/{1}", CompilableProject.LocalHost, ProjectService.CurrentProject.Name); } data.ProjectUrl = ProjectUrl.Text; @@ -197,7 +196,7 @@ 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); + data.ProjectUrl = string.Format(@"{0}:{1}/{2}", CompilableProject.LocalHost, PortTextBox.Text, ProjectService.CurrentProject.Name); CurrentProjectDebugData = data; } } diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/ProjectNodeCommands.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/ProjectNodeCommands.cs index aea7e82010..6c6e833336 100644 --- a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/ProjectNodeCommands.cs +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/ProjectNodeCommands.cs @@ -2,7 +2,9 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using System.IO; using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Gui.OptionPanels; namespace ICSharpCode.SharpDevelop.Project.Commands { diff --git a/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/SpecialFileNodeCommands.cs b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/SpecialFileNodeCommands.cs new file mode 100644 index 0000000000..4c0603e390 --- /dev/null +++ b/src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/SpecialFileNodeCommands.cs @@ -0,0 +1,74 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.IO; +using System.Linq; + +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Gui.OptionPanels; + +namespace ICSharpCode.SharpDevelop.Project.Commands +{ + public class ViewInBrowser : AbstractMenuCommand + { + public override void Run() + { + var node = ProjectBrowserPad.Instance.SelectedNode as FileNode; + if (node == null) { + return; + } + + var project = ProjectService.CurrentProject as CompilableProject; + if (project == null) { + return; + } + + if (!project.IsWebProject) { + MessageService.ShowError("${res:ProjectComponent.ContextMenu.NotAWebProject}"); + return; + } + + if (!WebProjectService.IsIISInstalled) { + MessageService.ShowError("${res:ICSharpCode.WepProjectOptionsPanel.IISNotFound}"); + return; + } + + string fileName = node.FileName; + + // set project options + project.StartAction = StartAction.StartURL; + string directoryName = Path.GetDirectoryName(project.FileName) + "\\"; + project.StartUrl = fileName.Replace(directoryName, "/").Replace("\\", "/"); + + // set web server options + string projectName = project.Name; + var existingOptions = WebProjectsOptions.Instance.GetWebProjectOptions(projectName); + + var options = new WebProjectOptions { + Data = new WebProjectDebugData { + WebServer = WebProjectService.IISVersion == IISVersion.IISExpress ? WebServer.IISExpress : WebServer.IIS, + Port = (existingOptions != null && existingOptions.Data != null) ? existingOptions.Data.Port : "8080", //TODO: port collision detection + ProjectUrl = string.Format("{0}/{1}", CompilableProject.LocalHost, project.Name) + }, + ProjectName = projectName + }; + + if (options.Data.WebServer == WebServer.IISExpress) { + options.Data.ProjectUrl = string.Format( + @"{0}:{1}/{2}", CompilableProject.LocalHost, options.Data.Port, projectName); + } + + WebProjectsOptions.Instance.SetWebProjectOptions(projectName, options); + + // create virtual directory + string error = WebProjectService.CreateVirtualDirectory( + projectName, + Path.GetDirectoryName(ProjectService.CurrentProject.FileName)); + LoggingService.Info(error ?? string.Empty); + + // RunProject + new RunProject().Run(); + } + } +} diff --git a/src/Main/Base/Project/Src/Internal/ConditionEvaluators/ViewInBrowserConditionEvaluator.cs b/src/Main/Base/Project/Src/Internal/ConditionEvaluators/ViewInBrowserConditionEvaluator.cs new file mode 100644 index 0000000000..4370805e46 --- /dev/null +++ b/src/Main/Base/Project/Src/Internal/ConditionEvaluators/ViewInBrowserConditionEvaluator.cs @@ -0,0 +1,32 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.IO; +using System.Linq; + +using ICSharpCode.Core; +using ICSharpCode.SharpDevelop.Project; + +namespace ICSharpCode.SharpDevelop +{ + public class ViewInBrowserConditionEvaluator : IConditionEvaluator + { + public bool IsValid(object caller, Condition condition) + { + var node = ProjectBrowserPad.Instance.SelectedNode; + if (node == null) { + return false; + } + + string fileName = Path.GetFileName(node.FullPath); + + string[] extensions = condition["extensions"].Split(','); + if (!extensions.Any(e => fileName.EndsWith(e))) { + return false; + } + + return true; + } + } +} diff --git a/src/Main/Base/Project/Src/Project/CompilableProject.cs b/src/Main/Base/Project/Src/Project/CompilableProject.cs index 24b814be25..da001ca6a5 100644 --- a/src/Main/Base/Project/Src/Project/CompilableProject.cs +++ b/src/Main/Base/Project/Src/Project/CompilableProject.cs @@ -31,6 +31,8 @@ namespace ICSharpCode.SharpDevelop.Project /// public abstract class CompilableProject : MSBuildBasedProject, IUpgradableProject { + public const string LocalHost = "http://localhost"; + #region Static methods /// /// Gets the file extension of the assembly created when building a project @@ -284,7 +286,7 @@ namespace ICSharpCode.SharpDevelop.Project switch (this.StartAction) { case StartAction.Project: if (IsWebProject) - return new ProcessStartInfo("http://localhost"); + return new ProcessStartInfo(LocalHost); return CreateStartInfo(this.OutputAssemblyFullPath); case StartAction.Program: diff --git a/src/Main/Base/Project/Src/Services/WebProjectService/WebProjectService.cs b/src/Main/Base/Project/Src/Services/WebProjectService/WebProjectService.cs index a674c126dd..17c14450f3 100644 --- a/src/Main/Base/Project/Src/Services/WebProjectService/WebProjectService.cs +++ b/src/Main/Base/Project/Src/Services/WebProjectService/WebProjectService.cs @@ -15,7 +15,7 @@ namespace ICSharpCode.SharpDevelop.Project public enum IISVersion { None = 0, - IISExpress, + IISExpress = 4, IIS5 = 5, IIS6, IIS7, @@ -157,7 +157,7 @@ namespace ICSharpCode.SharpDevelop.Project /// public static bool IsIISInstalled { get { - return (int)IISVersion > 4; + return (int)IISVersion >= 4; } } @@ -191,7 +191,7 @@ namespace ICSharpCode.SharpDevelop.Project /// /// Virtual directory name. /// Physical path. - /// + /// Error string or string null = no errors. public static string CreateVirtualDirectory(string virtualDirectoryName, string physicalDirectoryPath) { try { diff --git a/src/Main/StartUp/Project/Resources/BitmapResources.resources b/src/Main/StartUp/Project/Resources/BitmapResources.resources index 205ce25ea2..acd0bcaf1d 100644 Binary files a/src/Main/StartUp/Project/Resources/BitmapResources.resources and b/src/Main/StartUp/Project/Resources/BitmapResources.resources differ