CreateExecutionCommand() public method

public CreateExecutionCommand ( MonoDevelop.Projects.ConfigurationSelector conf ) : MonoDevelop.Core.Execution.NativeExecutionCommand
conf MonoDevelop.Projects.ConfigurationSelector
return MonoDevelop.Core.Execution.NativeExecutionCommand
示例#1
0
        internal static void ExecuteProject(DubProject prj, IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
        {
            bool isDebug = context.ExecutionHandler.GetType().Name.StartsWith("Debug");

            var      conf = prj.GetConfiguration(configuration) as DubProjectConfiguration;
            IConsole console;

            if (conf.ExternalConsole)
            {
                console = context.ExternalConsoleFactory.CreateConsole(!conf.PauseConsoleOutput);
            }
            else
            {
                console = context.ConsoleFactory.CreateConsole(true);
            }

            var operationMonitor = new AggregatedOperationMonitor(monitor);

            var sr = new StringBuilder();

            if (!isDebug)
            {
                sr.Append("run");
                BuildCommonArgAppendix(sr, prj, configuration);
            }

            try
            {
                var cmd = isDebug ? prj.CreateExecutionCommand(configuration) : new NativeExecutionCommand(DubSettings.Instance.DubCommand, sr.ToString(), prj.BaseDirectory.ToString());
                if (!context.ExecutionHandler.CanExecute(cmd))
                {
                    monitor.ReportError("Cannot execute \"" + cmd.Command + " " + cmd.Arguments + "\". The selected execution mode is not supported for Dub projects.", null);
                    return;
                }

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

                operationMonitor.AddOperation(op);
                op.WaitForCompleted();

                if (op.ExitCode != 0)
                {
                    monitor.ReportError(cmd.Command + " exited with code: " + op.ExitCode.ToString(), null);
                }
                else
                {
                    monitor.Log.WriteLine(cmd.Command + " exited with code: {0}", op.ExitCode);
                }
            }
            catch (Exception ex)
            {
                monitor.ReportError("Cannot execute \"" + sr.ToString() + "\"", ex);
            }
            finally
            {
                operationMonitor.Dispose();
                console.Dispose();
            }
        }
示例#2
0
		public static void ExecuteProject(DubProject prj,IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration, string dubVerb = "run")
		{
			bool isDebug = context.ExecutionHandler.GetType ().Name.StartsWith ("Debug");

			var conf = prj.GetConfiguration(configuration) as DubProjectConfiguration;
			IConsole console;
			if (conf.ExternalConsole)
				console = context.ExternalConsoleFactory.CreateConsole(!conf.PauseConsoleOutput);
			else
				console = context.ConsoleFactory.CreateConsole(true);
			
			var operationMonitor = new AggregatedOperationMonitor(monitor);

			var sr = new StringBuilder();
			if (!isDebug) {
				sr.Append (dubVerb);
				BuildCommonArgAppendix (sr, prj, configuration);
			}

			try
			{
				var cmd = isDebug ? prj.CreateExecutionCommand(configuration) : new NativeExecutionCommand(DubSettings.Instance.DubCommand, sr.ToString(), prj.BaseDirectory.ToString());
				if (!context.ExecutionHandler.CanExecute(cmd))
				{
					monitor.ReportError("Cannot execute \"" + cmd.Command + " " + cmd.Arguments + "\". The selected execution mode is not supported for Dub projects.", null);
					return;
				}

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

				operationMonitor.AddOperation(op);
				op.WaitForCompleted();

				if(op.ExitCode != 0)
					monitor.ReportError(cmd.Command+" exited with code: "+op.ExitCode.ToString(), null);
				else
					monitor.Log.WriteLine(cmd.Command+" exited with code: {0}", op.ExitCode);
			}
			catch (Exception ex)
			{
				monitor.ReportError("Cannot execute \"" + sr.ToString() + "\"", ex);
			}
			finally
			{
				operationMonitor.Dispose();
				console.Dispose();
			}
		}