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.IsIISOrIISExpressInstalled) {
				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;
			WebProjectOptions existingOptions = WebProjectsOptions.Instance.GetWebProjectOptions(projectName);
				
			var options = new WebProjectOptions {
				Data = new WebProjectDebugData {
					WebServer = WebProjectService.IsIISExpressInstalled ? 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(
				options.Data.WebServer,
				projectName,
				Path.GetDirectoryName(ProjectService.CurrentProject.FileName));
			LoggingService.Info(error ?? string.Empty);
			
			// RunProject
			new RunProject().Run();
		}
		public void SetWebProjectOptions(string projectName, WebProjectOptions data)
		{
			var d = GetWebProjectOptions(projectName);
			if (d == null)
			{
				if (data == null)
					data = new WebProjectOptions() { ProjectName = projectName };
				
				options.Add(data);
			}
			else
			{
				int index = options.IndexOf(d);
				options[index] = data;
			}
		}
        public void SetWebProjectOptions(string projectName, WebProjectOptions data)
        {
            var d = GetWebProjectOptions(projectName);

            if (d == null)
            {
                if (data == null)
                {
                    data = new WebProjectOptions()
                    {
                        ProjectName = projectName
                    }
                }
                ;

                options.Add(data);
            }
            else
            {
                int index = options.IndexOf(d);
                options[index] = data;
            }
        }
Exemple #4
0
		void OnProcessCreated(System.Diagnostics.Process defaultAppProcess, WebProjectOptions debugData)
		{
			if (attached)
				return;
			string processName = WebProjectService.WorkerProcessName;
			var processes = System.Diagnostics.Process.GetProcesses();
			int index = processes.FindIndex(p => p.ProcessName.Equals(processName, StringComparison.OrdinalIgnoreCase));
			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(defaultAppProcess);
					if (!attached) {
						MessageService.ShowMessage(ResourceService.GetString("ICSharpCode.WepProjectOptionsPanel.UnableToAttach"));
					}
				}
			}
		}
		bool CheckWebProjectStartInfo(CompilableProject project, WebProjectOptions options)
		{
			if (project == null) {
				MessageService.ShowError("${res:ICSharpCode.WepProjectOptionsPanel.NoStartupProject}");
				return false;
			}
			
			if (options == null || options.Data == null) {
				MessageService.ShowError("${res:ICSharpCode.WepProjectOptionsPanel.NoProjectUrlOrProgramAction}");
				return false;
			}
			
			return true;
		}