Exemplo n.º 1
0
        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);
		}
Exemplo n.º 3
0
		public static string GetWorkerProcessName(WebProjectProperties properties)
		{
			if (properties.UseIISExpress) {
				return GetIISExpressWorkerProcessName();
			}
			return GetIISWorkerProcessName();
		}
Exemplo n.º 4
0
        public void UpdateWebProjectProperties(WebProjectProperties properties)
        {
            var projectExtension = new VisualStudioProjectExtension(properties);

            projectExtension.Save(msbuildProject);
            SetMSBuildProperty("UseIISExpress", properties.UseIISExpress);
        }
Exemplo n.º 5
0
 public static string GetWorkerProcessName(WebProjectProperties properties)
 {
     if (properties.UseIISExpress)
     {
         return(GetIISExpressWorkerProcessName());
     }
     return(GetIISWorkerProcessName());
 }
Exemplo n.º 6
0
 public WebProjectProperties GetWebProjectProperties()
 {
     if (HasWebProjectProperties())
     {
         var projectExtension            = new VisualStudioProjectExtension(msbuildProject);
         WebProjectProperties properties = projectExtension.GetWebProjectProperties();
         properties.UseIISExpress = UseIISExpress;
         return(properties);
     }
     return(DefaultProperties);
 }
Exemplo n.º 7
0
		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);
		}
Exemplo n.º 8
0
 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));
 }
Exemplo n.º 9
0
		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);
			}
		}
Exemplo n.º 10
0
        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();
                }
            }
        }
Exemplo n.º 11
0
        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();
                }
            }
        }
Exemplo n.º 12
0
        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);
		}
Exemplo n.º 15
0
		void CreateWebProjectFromMSBuildProjectWithWebProjectProperties(WebProjectProperties properties)
		{
			CreateWebProject();
			webProject.UpdateWebProjectProperties(properties);
			CreateWebProject(msbuildProject);
		}
Exemplo n.º 16
0
		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);
		}
Exemplo n.º 21
0
        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();
            }
        }
Exemplo n.º 22
0
 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);
		}
Exemplo n.º 26
0
		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)
		{
		}
Exemplo n.º 28
0
		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);
		}
Exemplo n.º 30
0
		protected IISAdministrator(WebProjectProperties properties)
		{
			this.Properties = properties;
		}
 public VisualStudioProjectExtension(WebProjectProperties properties)
 {
     this.webProjectProperties = properties;
 }
		public VisualStudioProjectExtension(WebProjectProperties properties)
		{
			this.webProjectProperties = properties;
		}
Exemplo n.º 33
0
		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();
				}
			}
		}
Exemplo n.º 34
0
		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);
		}
Exemplo n.º 36
0
		public void UpdateWebProjectProperties_UseIISExpressIsTrue_MSBuildProjectIISExpressPropertySetToTrue()
		{
			CreateWebProject();
			var properties = new WebProjectProperties { UseIISExpress = true };
			
			webProject.UpdateWebProjectProperties(properties);
			
			string value = msbuildProject.GetEvaluatedProperty("UseIISExpress");
			
			Assert.AreEqual("True", value);
		}
Exemplo n.º 37
0
        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();
            }
        }
Exemplo n.º 38
0
 public IISExpressAdministrator(WebProjectProperties properties)
     : base(properties)
 {
 }
		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);
		}
Exemplo n.º 42
0
		public void UpdateWebProjectProperties(WebProjectProperties properties)
		{
			var projectExtension = new VisualStudioProjectExtension(properties);
			projectExtension.Save(msbuildProject);
			SetMSBuildProperty("UseIISExpress", properties.UseIISExpress);
		}
 void CreateWebProject(MSBuildBasedProject project)
 {
     webProject = new WebProject(project);
     properties = webProject.GetWebProjectProperties();
 }