public SingleItemSolutionRunConfiguration (SolutionItem item, SolutionItemRunConfiguration config): base (item.ItemId + "|" + config?.Name)
		{
			Item = item;
			RunConfiguration = config;
			if (config != null && !config.IsDefaultConfiguration)
				SetName (item.Name + " – " + config.Name);
			else
				SetName (item.Name);
		}
 public SingleItemSolutionRunConfiguration(SolutionItem item, SolutionItemRunConfiguration config) : base(item.ItemId + "|" + config?.Name)
 {
     Item             = item;
     RunConfiguration = config;
     if (config != null && !config.IsDefaultConfiguration)
     {
         SetName(item.Name + " – " + config.Name);
     }
     else
     {
         SetName(item.Name);
     }
 }
		protected override Task OnExecute (ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
		{
			return new Task (delegate {
			});
		}
		protected async override Task OnExecute (ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
		{
			if (data == null || !data.SupportsIntegration || String.IsNullOrEmpty (data.ExecuteTargetName)) {
				await base.OnExecute (monitor, context, configuration, runConfiguration);
				return;
			}

			OperationConsole console = context.ConsoleFactory.CreateConsole ();
			monitor.BeginTask (GettextCatalog.GetString ("Executing {0}", Project.Name), 1);
			try
			{
				ProcessWrapper process = Runtime.ProcessService.StartProcess ("make",
					data.ExecuteTargetName,
					Project.BaseDirectory,
					console.Out,
					console.Error,
					null);

				await process.Task;

				monitor.Log.WriteLine (GettextCatalog.GetString ("The application exited with code: {0}", process.ExitCode));
				monitor.Step (1);
			} catch (Exception e) {
				monitor.ReportError (GettextCatalog.GetString ("Project could not be executed: "), e);
				return;
			} finally {
				monitor.EndTask ();
				console.Dispose ();
			}
		}
Esempio n. 5
0
        internal protected virtual bool OnGetCanExecute(ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
        {
            context.RunConfiguration = runConfiguration;
#pragma warning disable 618 // Type or member is obsolete
            return(OnGetCanExecute(context, configuration));

#pragma warning restore 618 // Type or member is obsolete
        }
		protected async override Task OnExecute (ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
		{
			//check XSP is available

			var cfg = GetConfiguration (configuration);
			var cmd = CreateExecutionCommand (configuration, cfg);
			var browserExcTarget = context.ExecutionTarget as BrowserExecutionTarget;

			OperationConsole console = null;

			bool isXsp = true; //FIXME: fix this when it might not be true - should delegate to the ExecutionHandler

			try {
				//HACK: check XSP exists first, because error UX is cleaner w/o displaying a blank console pad.
				if (isXsp) {
					try {
						AspNetExecutionHandler.GetXspPath ((AspNetExecutionCommand)cmd);
					} catch (UserException ex) {
						MessageService.ShowError (
							GettextCatalog.GetString ("Could not launch ASP.NET web server"),
						    ex.Message);
						throw;
					}
				}

				console = context.ConsoleFactory.CreateConsole (monitor.CancellationToken);

				// The running Port value is now captured in the XspBrowserLauncherConsole object
				string url = String.Format ("http://{0}", XspParameters.Address);


				if (isXsp) {
					console = new XspBrowserLauncherConsole (console, delegate (string port) {
						if (browserExcTarget != null)
							browserExcTarget.DesktopApp.Launch (String.Format("{0}:{1}", url, port));
						else
							BrowserLauncher.LaunchDefaultBrowser (String.Format("{0}:{1}", url, port));
					});
				}

				monitor.Log.WriteLine (GettextCatalog.GetString ("Running web server..."));

				var op = context.ExecutionHandler.Execute (cmd, console);

				if (!isXsp) {
					if (browserExcTarget != null)
						browserExcTarget.DesktopApp.Launch (url);
					else
						BrowserLauncher.LaunchDefaultBrowser (url);
				}

				using (monitor.CancellationToken.Register (op.Cancel))
					await op.Task;

				monitor.Log.WriteLine (GettextCatalog.GetString ("The web server exited with code: {0}", op.ExitCode));

			} catch (Exception ex) {
				if (!(ex is UserException)) {
					LoggingService.LogError ("Could not launch ASP.NET web server.", ex);
				}
				monitor.ReportError (GettextCatalog.GetString ("Could not launch web server."), ex);
			} finally {
				if (console != null)
					console.Dispose ();
			}
		}
Esempio n. 7
0
		/// <summary>
		/// Load configuration information for a solution
		/// </summary>
		public void Load (Solution sol, SolutionItem project, SolutionItemRunConfiguration runConfig)
		{
			currentSolutionConfigurations.Clear ();
			currentTargetPartitions.Clear ();
			reducedConfigurations.Clear ();

			if (sol == null)
				return;

			// Create a set of configuration partitions. Each partition will contain configurations
			// which are implicitly selected when selecting an execution target. For example, in
			// an iOS project we would have two partitions: 
			//   1) Debug|IPhoneSimulator, Release|IPhoneSimulator
			//      targets: iPhone, iPad
			//   2) Debug|IPhone, Release|IPhone
			//      targets: device

			List<TargetPartition> partitions = new List<TargetPartition> ();
			if (project != null) {
				foreach (var conf in project.Configurations) {
					var targets = project.GetExecutionTargets (conf.Selector, runConfig);
					if (!targets.Any ()) {
						targets = new ExecutionTarget[] { dummyExecutionTarget };
					}
					var parts = partitions.Where (p => targets.Any (p.Targets.Contains)).ToArray();
					if (parts.Length == 0) {
						// Create a new partition for this configuration
						var p = new TargetPartition ();
						p.Configurations.Add (conf.Id);
						p.Targets.UnionWith (targets);
						partitions.Add (p);
					}
					else if (parts.Length == 1) {
						// Register the configuration into an existing partition
						parts[0].Configurations.Add (conf.Id);
						parts[0].Targets.UnionWith (targets);
					}
					else {
						// The partitions have to be merged into a single one
						for (int n=1; n<parts.Length; n++) {
							parts[0].Configurations.UnionWith (parts[n].Configurations);
							parts[0].Targets.UnionWith (parts[n].Targets);
							partitions.Remove (parts[n]);
						}
					}
				}

				// The startup project configuration partitions are used to create solution configuration partitions

				foreach (var solConf in sol.Configurations) {
					var pconf = solConf.GetEntryForItem (project);
					if (pconf != null && pconf.Build) {
						var part = partitions.FirstOrDefault (p => p.Configurations.Contains (pconf.ItemConfiguration));
						if (part != null) {
							part.SolutionConfigurations.Add (solConf.Id);
							continue;
						}
					}
					// The solution configuration is not bound to the startup project
					// Add it to all partitions so that it can still take part of
					// the solution configuration simplification process
					foreach (var p in partitions)
						p.SolutionConfigurations.Add (solConf.Id);
				}
			}

			if (partitions.Count == 0) {
				// There is no startup project, just use all solution configurations in this case
				var p = new TargetPartition ();
				p.SolutionConfigurations.AddRange (sol.GetConfigurations ());
				partitions.Add (p);
			}

			// There can be several configurations with the same prefix and different platform but which build the same projects.
			// If all configurations with the same prefix are identical, all of them can be reduced into a single configuration
			// with no platform name. This loop detects such configurations

			var notReducibleConfigurations = new HashSet<string> ();

			foreach (var p in partitions) {
				var groupedConfigs = p.SolutionConfigurations.GroupBy (sc => {
					string name, plat;
					ItemConfiguration.ParseConfigurationId (sc, out name, out plat);
					return name;
				}).ToArray ();
				foreach (var confGroup in groupedConfigs) {
					var configs = confGroup.ToArray ();
					var baseConf = sol.Configurations[configs[0]];
					if (configs.Skip (1).All (c => ConfigurationEquals (sol, baseConf, sol.Configurations[c])))
						p.ReducedConfigurations.Add (confGroup.Key);
					else
						notReducibleConfigurations.Add (confGroup.Key);
				}
			}

			// To really be able to use reduced configuration names, all partitions must have that reduced configuration
			// Find the configurations that have been reduced in all partitions

			reducedConfigurations = new HashSet<string> (partitions.SelectMany (p => p.ReducedConfigurations));
			reducedConfigurations.ExceptWith (notReducibleConfigurations);

			// Final merge of configurations

			var result = new HashSet<string> ();
			foreach (var p in partitions)
				result.UnionWith (p.SolutionConfigurations);

			// Replace reduced configurations

			foreach (var reducedConf in reducedConfigurations) {
				result.RemoveWhere (c => {
					string name, plat;
					ItemConfiguration.ParseConfigurationId (c, out name, out plat);
					return name == reducedConf;
				});
				result.Add (reducedConf);
			}
			currentTargetPartitions = partitions;
			currentSolutionConfigurations.AddRange (result);
			currentSolutionConfigurations.Sort ();
		}
Esempio n. 8
0
		protected override bool OnGetCanExecute (ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
		{
			DotNetProjectConfiguration config = (DotNetProjectConfiguration)GetConfiguration (configuration);
			if (config == null)
				return false;
			
			var runConfig = runConfiguration as ProjectRunConfiguration;
			if (runConfig == null)
				return false;

			var asmRunConfig = runConfiguration as AssemblyRunConfiguration;
		
			ExecutionCommand executionCommand;

			if (asmRunConfig != null && asmRunConfig.StartAction == AssemblyRunConfiguration.StartActions.Program) {
				executionCommand = Runtime.ProcessService.CreateCommand (asmRunConfig.StartProgram);
				// If it is command for executing an assembly, add runtime options
				var dcmd = executionCommand as DotNetExecutionCommand;
				if (dcmd != null) {
					string monoOptions;
					asmRunConfig.MonoParameters.GenerateOptions (dcmd.EnvironmentVariables, out monoOptions);
					dcmd.RuntimeArguments = monoOptions;
				}
				// If it is command for executing a process, add arguments, work directory and env vars
				var pcmd = executionCommand as ProcessExecutionCommand;
				if (pcmd != null) {
					pcmd.Arguments = asmRunConfig.StartArguments;
					pcmd.WorkingDirectory = asmRunConfig.StartWorkingDirectory;

					foreach (var env in asmRunConfig.EnvironmentVariables)
						pcmd.EnvironmentVariables [env.Key] = env.Value;
				}
			} else {
				executionCommand = CreateExecutionCommand (configuration, config, runConfig);
				if (context.ExecutionTarget != null)
					executionCommand.Target = context.ExecutionTarget;
			}

			return executionCommand != null && context.ExecutionHandler.CanExecute (executionCommand);
		}
		protected override bool OnGetCanExecute (MonoDevelop.Projects.ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
		{
			if (runConfiguration == unitTestingRunConfigurationInstance) {
				UnitTest test = FindRootTest ();
				return (test != null) && test.CanRun (context.ExecutionHandler);
			}
			return base.OnGetCanExecute (context, configuration, runConfiguration);
		}
        protected override bool OnGetCanExecute(ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
        {
            ProjectConfiguration config = (ProjectConfiguration)GetConfiguration(configuration);

            if (config == null)
            {
                return(false);
            }
            if (!string.Equals(FileName.Extension, ".exe", StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }
            ExecutionCommand cmd = CreateExecutionCommand(configuration, config);

            return(context.ExecutionHandler.CanExecute(cmd));
        }
		internal protected virtual IEnumerable<ExecutionTarget> OnGetExecutionTargets (OperationContext ctx, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfig)
		{
			return next.OnGetExecutionTargets (ctx, configuration, runConfig);
		}
		internal protected virtual bool OnGetCanExecute (ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
		{
			context.RunConfiguration = runConfiguration;
#pragma warning disable 618 // Type or member is obsolete
			return OnGetCanExecute (context, configuration);
#pragma warning restore 618 // Type or member is obsolete
		}
		internal protected virtual Task OnExecute (ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
		{
			context.RunConfiguration = runConfiguration;
#pragma warning disable 618 // Type or member is obsolete
			return OnExecute (monitor, context, configuration);
#pragma warning restore 618 // Type or member is obsolete
		}
Esempio n. 14
0
 protected override Task OnExecute(ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
 {
     return(new Task(delegate {
     }));
 }
Esempio n. 15
0
 public StartupItem(SolutionItem item, SolutionItemRunConfiguration configuration)
 {
     SolutionItem     = item;
     RunConfiguration = configuration;
 }
		protected override async Task OnExecute (MonoDevelop.Core.ProgressMonitor monitor, MonoDevelop.Projects.ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
		{
			if (runConfiguration == unitTestingRunConfigurationInstance) {
				// The user selected to run the tests
				UnitTest test = FindRootTest ();
				if (test != null) {
					var cs = new CancellationTokenSource ();
					using (monitor.CancellationToken.Register (cs.Cancel))
						await UnitTestService.RunTest (test, context, false, false, cs);
				}
			} else
				await base.OnExecute (monitor, context, configuration, runConfiguration);
		}
		public override void Load (Project project, SolutionItemRunConfiguration config)
		{
			widget.Load ((ProcessRunConfiguration)config);
		}
		public override void Load (Project project, SolutionItemRunConfiguration config)
		{
			widget.Load (project, (AssemblyRunConfiguration)config);
			widget.Changed += (sender, e) => NotifyChanged ();
		}
Esempio n. 19
0
		protected async override Task OnExecute (ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
		{
			DotNetProjectConfiguration dotNetProjectConfig = GetConfiguration (configuration) as DotNetProjectConfiguration;
			if (dotNetProjectConfig == null) {
				monitor.ReportError (GettextCatalog.GetString ("Configuration '{0}' not found in project '{1}'", configuration, Name), null);
				return;
			}

			monitor.Log.WriteLine (GettextCatalog.GetString ("Running {0} ...", dotNetProjectConfig.CompiledOutputName));

			ExecutionCommand executionCommand = CreateExecutionCommand (configuration, dotNetProjectConfig, runConfiguration as ProjectRunConfiguration);
			if (context.ExecutionTarget != null)
				executionCommand.Target = context.ExecutionTarget;

			if (!context.ExecutionHandler.CanExecute (executionCommand)) {
				monitor.ReportError (GettextCatalog.GetString ("Can not execute \"{0}\". The selected execution mode is not supported for .NET projects.", dotNetProjectConfig.CompiledOutputName), null);
				return;
			}

			try {
				await ProjectExtension.OnExecuteCommand (monitor, context, configuration, executionCommand);
			} catch (Exception ex) {
				LoggingService.LogError (string.Format ("Cannot execute \"{0}\"", dotNetProjectConfig.CompiledOutputName), ex);
				monitor.ReportError (GettextCatalog.GetString ("Cannot execute \"{0}\"", dotNetProjectConfig.CompiledOutputName), ex);
			}
		}
Esempio n. 20
0
        protected async override Task OnExecute(ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
        {
            ProjectConfiguration conf = (ProjectConfiguration)GetConfiguration(configuration);

            monitor.Log.WriteLine(GettextCatalog.GetString("Running {0} ...", FileName));

            OperationConsole console = conf.ExternalConsole
                                ? context.ExternalConsoleFactory.CreateConsole(!conf.PauseConsoleOutput, monitor.CancellationToken)
                                                                                   : context.ConsoleFactory.CreateConsole(
                OperationConsoleFactory.CreateConsoleOptions.Default.WithTitle(Path.GetFileName(FileName)), monitor.CancellationToken);

            try {
                try {
                    ExecutionCommand executionCommand = CreateExecutionCommand(configuration, conf);

                    if (!context.ExecutionHandler.CanExecute(executionCommand))
                    {
                        monitor.ReportError(GettextCatalog.GetString("Can not execute \"{0}\". The selected execution mode is not supported for .NET projects.", FileName), null);
                        return;
                    }

                    ProcessAsyncOperation asyncOp = context.ExecutionHandler.Execute(executionCommand, console);
                    var stopper = monitor.CancellationToken.Register(asyncOp.Cancel);

                    await asyncOp.Task;

                    stopper.Dispose();

                    monitor.Log.WriteLine(GettextCatalog.GetString("The application exited with code: {0}", asyncOp.ExitCode));
                } finally {
                    console.Dispose();
                }
            } catch (Exception ex) {
                LoggingService.LogError(string.Format("Cannot execute \"{0}\"", FileName), ex);
                monitor.ReportError(GettextCatalog.GetString("Cannot execute \"{0}\"", FileName), ex);
            }
        }
Esempio n. 21
0
		protected override bool OnGetCanExecute (ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
		{
			var cmd = CreateExecutionCommand (configuration, GetConfiguration (configuration));
			return context.ExecutionHandler.CanExecute (cmd);
		}
Esempio n. 22
0
        protected override bool OnGetCanExecute(ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
        {
            ProjectConfiguration config = (ProjectConfiguration)GetConfiguration(configuration);

            if (config == null)
            {
                return(false);
            }
            if (FileName.Extension.ToLower() != ".exe")
            {
                return(false);
            }
            ExecutionCommand cmd = CreateExecutionCommand(configuration, config);

            return(context.ExecutionHandler.CanExecute(cmd));
        }
Esempio n. 23
0
        internal protected virtual Task OnExecute(ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
        {
            context.RunConfiguration = runConfiguration;
#pragma warning disable 618 // Type or member is obsolete
            return(OnExecute(monitor, context, configuration));

#pragma warning restore 618 // Type or member is obsolete
        }
		public abstract void Load (Project project, SolutionItemRunConfiguration config);
Esempio n. 25
0
 internal protected virtual IEnumerable <ExecutionTarget> OnGetExecutionTargets(OperationContext ctx, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfig)
 {
     return(next.OnGetExecutionTargets(ctx, configuration, runConfig));
 }
		protected override bool OnGetCanExecute (ExecutionContext context, ConfigurationSelector configuration, SolutionItemRunConfiguration runConfiguration)
		{
			if (data != null && data.SupportsIntegration && !String.IsNullOrEmpty (data.ExecuteTargetName))
				return true;
			return base.OnGetCanExecute (context, configuration, runConfiguration);
		}