void OnProcessCreated(WebProjectProperties properties, bool withDebugging) { string processName = WebProjectService.GetWorkerProcessName(properties); Process[] processes = Process.GetProcesses(); int index = processes.FindIndex(p => p.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase)); if (index == -1) { return; } if (withDebugging) { DebuggerService.CurrentDebugger.Attach(processes[index]); if (!DebuggerService.CurrentDebugger.IsAttached) { if (properties.UseIIS) { string format = ResourceService.GetString("ICSharpCode.WebProjectOptionsPanel.NoIISWP"); MessageService.ShowMessage(string.Format(format, processName)); } } } }
void CreateMSBuildProjectWithWebProjectProperties() { CreateMSBuildProject(); var properties = new WebProjectProperties(); var extension = new VisualStudioProjectExtension(properties); extension.Save(msbuildProject); }
public static string GetWorkerProcessName(WebProjectProperties properties) { if (properties.UseIISExpress) { return GetIISExpressWorkerProcessName(); } return GetIISWorkerProcessName(); }
public void UpdateWebProjectProperties(WebProjectProperties properties) { var projectExtension = new VisualStudioProjectExtension(properties); projectExtension.Save(msbuildProject); SetMSBuildProperty("UseIISExpress", properties.UseIISExpress); }
public static string GetWorkerProcessName(WebProjectProperties properties) { if (properties.UseIISExpress) { return(GetIISExpressWorkerProcessName()); } return(GetIISWorkerProcessName()); }
public WebProjectProperties GetWebProjectProperties() { if (HasWebProjectProperties()) { var projectExtension = new VisualStudioProjectExtension(msbuildProject); WebProjectProperties properties = projectExtension.GetWebProjectProperties(); properties.UseIISExpress = UseIISExpress; return(properties); } return(DefaultProperties); }
bool Equals(WebProjectProperties properties) { return (AutoAssignPort == properties.AutoAssignPort) && (UseIIS == properties.UseIIS) && (DevelopmentServerVPath == properties.DevelopmentServerVPath) && (DevelopmentServerPort == properties.DevelopmentServerPort) && (CustomServerUrl == properties.CustomServerUrl) && (UseCustomServer == properties.UseCustomServer) && (SaveServerSettingsInUserFile == properties.SaveServerSettingsInUserFile) && (UseIISExpress == properties.UseIISExpress) && (NTLMAuthentication == properties.NTLMAuthentication) && (IISUrl == properties.IISUrl); }
bool Equals(WebProjectProperties properties) { return ((AutoAssignPort == properties.AutoAssignPort) && (UseIIS == properties.UseIIS) && (DevelopmentServerVPath == properties.DevelopmentServerVPath) && (DevelopmentServerPort == properties.DevelopmentServerPort) && (CustomServerUrl == properties.CustomServerUrl) && (UseCustomServer == properties.UseCustomServer) && (SaveServerSettingsInUserFile == properties.SaveServerSettingsInUserFile) && (UseIISExpress == properties.UseIISExpress) && (NTLMAuthentication == properties.NTLMAuthentication) && (IISUrl == properties.IISUrl)); }
public static IISAdministrator CreateAdministrator(WebProjectProperties properties) { if (properties.UseIISExpress) { return new IISExpressAdministrator(properties); } switch (WebProjectService.IISVersion) { case IISVersion.IIS5: case IISVersion.IIS6: return new IIS6Administrator(properties); case IISVersion.None: return new NullIISAdministrator(); default: return new IIS7Administrator(properties); } }
void AttachToWebWorkerProcessOrStartIISExpress(WebProjectProperties properties, bool withDebugging) { string processName = WebProjectService.GetWorkerProcessName(properties); // try find the worker process directly or using the process monitor callback Process[] processes = System.Diagnostics.Process.GetProcesses(); int index = Array.FindIndex(processes, p => properties.UseIISExpress ? p.Id == LastStartedIISExpressProcessId : p.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase)); if (index > -1) { if (withDebugging) { SD.Debugger.Attach(processes[index]); } } else { if (properties.UseIISExpress) { // start IIS express and attach to it if (WebProjectService.IsIISExpressInstalled) { ProcessStartInfo processInfo = IISExpressProcessStartInfo.Create(WebProject); if (withDebugging) { SD.Debugger.Start(processInfo); } else { var process = Process.Start(processInfo); LastStartedIISExpressProcessId = process.Id; } } } else { DisposeProcessMonitor(); this.monitor = new ProcessMonitor(processName); this.monitor.ProcessCreated += delegate { SD.MainThread.InvokeAsyncAndForget(() => OnProcessCreated(properties, withDebugging)); }; this.monitor.Start(); } } }
void AttachToWebWorkerProcessOrStartIISExpress(WebProjectProperties properties, bool withDebugging) { string processName = WebProjectService.GetWorkerProcessName(properties); // try find the worker process directly or using the process monitor callback Process[] processes = System.Diagnostics.Process.GetProcesses(); int index = processes.FindIndex(p => p.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase)); if (index > -1) { if (withDebugging) { DebuggerService.CurrentDebugger.Attach(processes[index]); } } else { if (properties.UseIISExpress) { // start IIS express and attach to it if (WebProjectService.IsIISExpressInstalled) { ProcessStartInfo processInfo = IISExpressProcessStartInfo.Create(WebProject); if (withDebugging) { DebuggerService.CurrentDebugger.Start(processInfo); } else { Process.Start(processInfo); } } } else { DisposeProcessMonitor(); this.monitor = new ProcessMonitor(processName); this.monitor.ProcessCreated += delegate { WorkbenchSingleton.SafeThreadCall((Action)(() => OnProcessCreated(properties, withDebugging))); }; this.monitor.Start(); } } }
public static IISAdministrator CreateAdministrator(WebProjectProperties properties) { if (properties.UseIISExpress) { return(new IISExpressAdministrator(properties)); } switch (WebProjectService.IISVersion) { case IISVersion.IIS5: case IISVersion.IIS6: return(new IIS6Administrator(properties)); case IISVersion.None: return(new NullIISAdministrator()); default: return(new IIS7Administrator(properties)); } }
public void Constructor_XElementHasCustomServerUrl_CustomServerUrlPropertyPopulated() { var properties = new WebProjectProperties() { CustomServerUrl = "/Test" }; properties = new WebProjectProperties(properties.ToXElement()); Assert.AreEqual("/Test", properties.CustomServerUrl); }
public void IsConfigured_UseIISExpressIsTrueAndIISUrlIsValidUrl_ReturnsTrue() { var properties = new WebProjectProperties { UseIISExpress = true, IISUrl = "http://localhost:8080/" }; bool configured = properties.IsConfigured(); Assert.IsTrue(configured); }
void CreateWebProjectFromMSBuildProjectWithWebProjectProperties(WebProjectProperties properties) { CreateWebProject(); webProject.UpdateWebProjectProperties(properties); CreateWebProject(msbuildProject); }
public void GetWebProjectProperties_MSBuildHasUseIISExpressPropertySetToTrue_UseIISExpressPropertyIsTrue() { CreateWebProjectFromMSBuildProjectWithWebProjectProperties(); SetUseIISExpressInMSBuildProjectToTrue(); var properties = webProject.GetWebProjectProperties(); var expectedProperties = new WebProjectProperties { UseIISExpress = true }; Assert.AreEqual(expectedProperties, properties); }
public void Constructor_WebPropertyPropertiesXElementHasNoChildElements_ExceptionNotThrown() { var element = new XElement("WebPropertyProperties"); var properties = new WebProjectProperties(element); Assert.AreEqual(String.Empty, properties.IISUrl); Assert.AreEqual(String.Empty, properties.CustomServerUrl); }
public void Constructor_XElementHasUseIIS_UseIISPropertyPopulated() { var properties = new WebProjectProperties() { UseIIS = true }; properties = new WebProjectProperties(properties.ToXElement()); Assert.IsTrue(properties.UseIIS); }
void CreateWebProject(MSBuildBasedProject project) { webProject = new WebProject(project); properties = webProject.GetWebProjectProperties(); }
public void Constructor_XElementHasDevelopmentServerVPath_DevelopmentServerVPathPropertyPopulated() { var properties = new WebProjectProperties() { DevelopmentServerVPath = "Test" }; properties = new WebProjectProperties(properties.ToXElement()); Assert.AreEqual("Test", properties.DevelopmentServerVPath); }
public override void Start(bool withDebugging) { if (!CheckWebProjectStartInfo()) { return; } try { WebProjectProperties properties = WebProject.GetWebProjectProperties(); string processName = WebProjectService.GetWorkerProcessName(properties); // try find the worker process directly or using the process monitor callback Process[] processes = System.Diagnostics.Process.GetProcesses(); int index = processes.FindIndex(p => p.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase)); if (index > -1) { if (withDebugging) { DebuggerService.CurrentDebugger.Attach(processes[index]); } } else { if (properties.UseIISExpress) { // start IIS express and attach to it if (WebProjectService.IsIISExpressInstalled) { ProcessStartInfo processInfo = IISExpressProcessStartInfo.Create(WebProject); DebuggerService.CurrentDebugger.Start(processInfo); } else { DisposeProcessMonitor(); MessageService.ShowError("${res:ICSharpCode.WebProjectOptionsPanel.NoProjectUrlOrProgramAction}"); return; } } else { DisposeProcessMonitor(); this.monitor = new ProcessMonitor(processName); this.monitor.ProcessCreated += delegate { WorkbenchSingleton.SafeThreadCall((Action)(() => OnProcessCreated(properties, withDebugging))); }; this.monitor.Start(); } } // start default application(e.g. browser) or the one specified switch (CompilableProject.StartAction) { case StartAction.Project: if (FileUtility.IsUrl(properties.IISUrl)) { Process.Start(properties.IISUrl); } else { MessageService.ShowError("${res:ICSharpCode.WebProjectOptionsPanel.NoProjectUrlOrProgramAction}"); DisposeProcessMonitor(); } break; case StartAction.Program: Process.Start(StartProgram); break; case StartAction.StartURL: if (FileUtility.IsUrl(StartUrl)) { Process.Start(StartUrl); } else { string url = string.Concat(properties.IISUrl, StartUrl); if (FileUtility.IsUrl(url)) { Process.Start(url); } else { MessageService.ShowError("${res:ICSharpCode.WebProjectOptionsPanel.NoProjectUrlOrProgramAction}"); DisposeProcessMonitor(); return; } } break; default: throw new Exception("Invalid value for StartAction"); } } catch (Exception ex) { MessageService.ShowError(ex.Message); LoggingService.Error(ex.ToString()); DisposeProcessMonitor(); } }
protected IISAdministrator(WebProjectProperties properties) { this.Properties = properties; }
void CreateTwoWebProjectProperties() { lhs = new WebProjectProperties(); rhs = new WebProjectProperties(); }
public void IsConfigured_UseIISIsTrueAndIISUrlIsNull_ReturnsFalse() { var properties = new WebProjectProperties { UseIISExpress = true, IISUrl = null }; bool configured = properties.IsConfigured(); Assert.IsFalse(configured); }
public void IsConfigured_UseIISExpressIsTrueAndIISUrlIsEmptyString_ReturnsFalse() { var properties = new WebProjectProperties { UseIISExpress = true, IISUrl = String.Empty }; bool configured = properties.IsConfigured(); Assert.IsFalse(configured); }
void AttachToWebWorkerProcessOrStartIISExpress(WebProjectProperties properties, bool withDebugging) { string processName = WebProjectService.GetWorkerProcessName(properties); // try find the worker process directly or using the process monitor callback Process[] processes = System.Diagnostics.Process.GetProcesses(); int index = Array.FindIndex(processes, p => properties.UseIISExpress ? p.Id == LastStartedIISExpressProcessId : p.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase)); if (index > -1) { if (withDebugging) SD.Debugger.Attach(processes[index]); } else { if (properties.UseIISExpress) { // start IIS express and attach to it if (WebProjectService.IsIISExpressInstalled) { ProcessStartInfo processInfo = IISExpressProcessStartInfo.Create(WebProject); if (withDebugging) { SD.Debugger.Start(processInfo); } else { var process = Process.Start(processInfo); LastStartedIISExpressProcessId = process.Id; } } } else { DisposeProcessMonitor(); this.monitor = new ProcessMonitor(processName); this.monitor.ProcessCreated += delegate { SD.MainThread.InvokeAsyncAndForget(() => OnProcessCreated(properties, withDebugging)); }; this.monitor.Start(); } } }
public IISExpressAdministrator(WebProjectProperties properties) : base(properties) { }
void OnProcessCreated(WebProjectProperties properties, bool withDebugging) { string processName = WebProjectService.GetWorkerProcessName(properties); Process[] processes = Process.GetProcesses(); int index = Array.FindIndex(processes, p => p.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase)); if (index == -1) return; if (withDebugging) { SD.Debugger.Attach(processes[index]); if (!SD.Debugger.IsAttached) { if(properties.UseIIS) { string format = ResourceService.GetString("ICSharpCode.WebProjectOptionsPanel.NoIISWP"); MessageService.ShowMessage(string.Format(format, processName)); } } } }
public void Constructor_XElementHasUseCustomServer_UseCustomServerPropertyPopulated() { var properties = new WebProjectProperties() { UseCustomServer = true }; properties = new WebProjectProperties(properties.ToXElement()); Assert.IsTrue(properties.UseCustomServer); }
public VisualStudioProjectExtension(WebProjectProperties properties) { this.webProjectProperties = properties; }
void AttachToWebWorkerProcessOrStartIISExpress(WebProjectProperties properties, bool withDebugging) { string processName = WebProjectService.GetWorkerProcessName(properties); // try find the worker process directly or using the process monitor callback Process[] processes = System.Diagnostics.Process.GetProcesses(); int index = processes.FindIndex(p => p.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase)); if (index > -1) { if (withDebugging) DebuggerService.CurrentDebugger.Attach(processes[index]); } else { if (properties.UseIISExpress) { // start IIS express and attach to it if (WebProjectService.IsIISExpressInstalled) { ProcessStartInfo processInfo = IISExpressProcessStartInfo.Create(WebProject); if (withDebugging) DebuggerService.CurrentDebugger.Start(processInfo); else Process.Start(processInfo); } } else { DisposeProcessMonitor(); this.monitor = new ProcessMonitor(processName); this.monitor.ProcessCreated += delegate { WorkbenchSingleton.SafeThreadCall((Action)(() => OnProcessCreated(properties, withDebugging))); }; this.monitor.Start(); } } }
public void GetWebProjectProperties_MSBuildHasWebProjectProperties_ReadsWebProjectPropertiesFromMSBuildProject() { var expectedProperties = new WebProjectProperties { DevelopmentServerPort = 8989, IISUrl = "http://localhost:8989/test" }; CreateWebProjectFromMSBuildProjectWithWebProjectProperties(expectedProperties); WebProjectProperties properties = webProject.GetWebProjectProperties(); Assert.AreEqual(expectedProperties, properties); }
public void Constructor_XElementHasSaveServerSettingsInUserFile_SaveServerSettingsInUserFilePropertyPopulated() { var properties = new WebProjectProperties() { SaveServerSettingsInUserFile = true }; properties = new WebProjectProperties(properties.ToXElement()); Assert.IsTrue(properties.SaveServerSettingsInUserFile); }
public void UpdateWebProjectProperties_UseIISExpressIsTrue_MSBuildProjectIISExpressPropertySetToTrue() { CreateWebProject(); var properties = new WebProjectProperties { UseIISExpress = true }; webProject.UpdateWebProjectProperties(properties); string value = msbuildProject.GetEvaluatedProperty("UseIISExpress"); Assert.AreEqual("True", value); }
public override void Start(bool withDebugging) { try { WebProjectProperties properties = WebProject.GetWebProjectProperties(); if (CheckWebProjectStartInfo()) { AttachToWebWorkerProcessOrStartIISExpress(properties, withDebugging); } // start default application(e.g. browser) or the one specified switch (CompilableProject.StartAction) { case StartAction.Project: if (FileUtility.IsUrl(properties.IISUrl)) { Process.Start(properties.IISUrl); } else { MessageService.ShowError("${res:ICSharpCode.WebProjectOptionsPanel.NoProjectUrlOrProgramAction}"); DisposeProcessMonitor(); } break; case StartAction.Program: ProcessStartInfo processInfo = DotNetStartBehavior.CreateStartInfo(StartProgram, Project.Directory, StartWorkingDirectory, StartArguments); if (withDebugging) { DebuggerService.CurrentDebugger.Start(processInfo); } else { Process.Start(processInfo); } break; case StartAction.StartURL: if (FileUtility.IsUrl(StartUrl)) { Process.Start(StartUrl); } else { string url = string.Concat(properties.IISUrl, StartUrl); if (FileUtility.IsUrl(url)) { Process.Start(url); } else { MessageService.ShowError("${res:ICSharpCode.WebProjectOptionsPanel.NoProjectUrlOrProgramAction}"); DisposeProcessMonitor(); return; } } break; default: throw new Exception("Invalid value for StartAction"); } } catch (Exception ex) { MessageService.ShowError(ex.Message); LoggingService.Error(ex.ToString()); DisposeProcessMonitor(); } }
public void IsConfigured_UseIISAndUseIISExpressAreBothFalse_ReturnsFalse() { var properties = new WebProjectProperties() { UseIISExpress = false, UseIIS = false }; bool configured = properties.IsConfigured(); Assert.IsFalse(configured); }
public void Constructor_XElementHasAutoAssignPort_AutoAssignPortPropertyPopulated() { var properties = new WebProjectProperties() { AutoAssignPort = true }; properties = new WebProjectProperties(properties.ToXElement()); Assert.IsTrue(properties.AutoAssignPort); }
public void Constructor_XElementHasNTLMAuthentication_NTLMAuthenticationPropertyPopulated() { var properties = new WebProjectProperties() { NTLMAuthentication = true }; properties = new WebProjectProperties(properties.ToXElement()); Assert.IsTrue(properties.NTLMAuthentication); }