protected override void DoExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
        {
            IodineConfiguration config = (IodineConfiguration)GetConfiguration (configuration);
            IConsole console = config.ExternalConsole ?
                context.ExternalConsoleFactory.CreateConsole (!config.PauseConsoleOutput) :
                context.ConsoleFactory.CreateConsole (!config.PauseConsoleOutput);

            AggregatedOperationMonitor aggregatedMonitor = new AggregatedOperationMonitor (monitor);
            try {
                string param = string.Format ("\"{0}\" {1}", config.MainFile, config.CommandLineParameters);

                IProcessAsyncOperation op = Runtime.ProcessService.StartConsoleProcess ("iodine",
                        param, BaseDirectory,
                        config.EnvironmentVariables, console, null);

                monitor.CancelRequested += delegate {
                    op.Cancel ();
                };

                aggregatedMonitor.AddOperation (op);
                op.WaitForCompleted ();
                monitor.Log.WriteLine ("Iodine exited with code: " + op.ExitCode);

            } catch (Exception e) {
                monitor.ReportError (GettextCatalog.GetString ("Cannot execute \"{0}\"", config.MainFile), e);
            } finally {
                console.Dispose ();
                aggregatedMonitor.Dispose ();
            }
        }
示例#2
0
        internal static void ExecuteProject(DubProject prj,IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
        {
            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("run");
            Instance.BuildCommonArgAppendix(sr, prj, configuration);

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

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

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

                monitor.Log.WriteLine(Instance.DubExecutable+" exited with code: {0}", op.ExitCode);

            }
            catch (Exception ex)
            {
                monitor.ReportError("Cannot execute \"" + sr.ToString() + "\"", ex);
            }
            finally
            {
                operationMonitor.Dispose();
                console.Dispose();
            }
        }
        protected override void DoExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
        {
            var config = GetConfiguration (configuration) as DotNetProjectConfiguration;
            monitor.Log.WriteLine (GettextCatalog.GetString ("Running {0} ...", Name));

            IConsole console = CreateConsole (config, context);
            var aggregatedOperationMonitor = new AggregatedOperationMonitor (monitor);

            try {
                try {
                    ExecutionCommand executionCommand = CreateExecutionCommand (configuration, config);
                    if (context.ExecutionTarget != null)
                        executionCommand.Target = context.ExecutionTarget;

                    IProcessAsyncOperation asyncOp = new DnxExecutionHandler ().Execute (executionCommand, console);
                    aggregatedOperationMonitor.AddOperation (asyncOp);
                    asyncOp.WaitForCompleted ();

                    monitor.Log.WriteLine (GettextCatalog.GetString ("The application exited with code: {0}", asyncOp.ExitCode));
                } finally {
                    console.Dispose ();
                    aggregatedOperationMonitor.Dispose ();
                }
            } catch (Exception ex) {
                LoggingService.LogError (string.Format ("Cannot execute \"{0}\"", Name), ex);
                monitor.ReportError (GettextCatalog.GetString ("Cannot execute \"{0}\"", Name), ex);
            }
        }
        protected override void DoExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
        {
            if (!CheckCanExecute (configuration))
                return;

            var config = (PythonConfiguration) GetConfiguration (configuration);
            IConsole console = config.ExternalConsole ?
                context.ExternalConsoleFactory.CreateConsole (!config.PauseConsoleOutput) :
                context.ConsoleFactory.CreateConsole (!config.PauseConsoleOutput);

            var aggregatedMonitor = new AggregatedOperationMonitor (monitor);

            try {
                var executionCommand = CreateExecutionCommand (configuration, config);
                if (!context.ExecutionHandler.CanExecute (executionCommand)) {
                    monitor.ReportError (GettextCatalog.GetString ("Cannot execute application. The selected execution mode " +
                        "is not supported for IronPython projects"), null);
                    return;
                }

                var asyncOp = context.ExecutionHandler.Execute (executionCommand, console);
                aggregatedMonitor.AddOperation (asyncOp);
                asyncOp.WaitForCompleted ();

                monitor.Log.WriteLine ("The application exited with code: " + asyncOp.ExitCode);

            } catch (Exception exc) {
                monitor.ReportError (GettextCatalog.GetString ("Cannot execute \"{0}\"", config.MainModule), exc);
            } finally {
                console.Dispose ();
                aggregatedMonitor.Dispose ();
            }
        }
        public static void Run(HaxeProject project, HaxeProjectConfiguration configuration, IProgressMonitor monitor, ExecutionContext context)
        {
            ExecutionCommand cmd = CreateExecutionCommand (project, configuration);

            if (cmd is NativeExecutionCommand)
            {
                IConsole console;
                if (configuration.ExternalConsole)
                    console = context.ExternalConsoleFactory.CreateConsole (false);
                else
                    console = context.ConsoleFactory.CreateConsole (false);

                AggregatedOperationMonitor operationMonitor = new AggregatedOperationMonitor (monitor);

                try
                {
                    if (!context.ExecutionHandler.CanExecute (cmd))
                    {
                        monitor.ReportError (String.Format ("Cannot execute '{0}'.", cmd.CommandString), null);
                        return;
                    }

                    IProcessAsyncOperation operation = context.ExecutionHandler.Execute (cmd, console);

                    operationMonitor.AddOperation (operation);
                    operation.WaitForCompleted ();

                    monitor.Log.WriteLine ("Player exited with code {0}.", operation.ExitCode);
                }
                catch (Exception)
                {
                    monitor.ReportError (String.Format ("Error while executing '{0}'.", cmd.CommandString), null);
                }
                finally
                {
                    operationMonitor.Dispose ();
                    console.Dispose ();
                }
            }
            else
            {
                Process.Start (cmd.CommandString);
            }
        }
示例#6
0
        /// <summary>
        /// Executes a file and reports events related to the execution to the 'monitor' passed in the parameters.
        /// </summary>
        static int ExecuteCommand(
            string command,
            string args,
            string baseDirectory,

            IProgressMonitor monitor,
            out string errorOutput,
            out string programOutput)
        {
            errorOutput = string.Empty;
            int exitCode = -1;

            var swError = new StringWriter ();
            var swOutput = new StringWriter ();

            var chainedError = new LogTextWriter ();
            chainedError.ChainWriter (monitor.Log);
            chainedError.ChainWriter (swError);

            var chainedOutput = new LogTextWriter ();
            chainedOutput.ChainWriter (monitor.Log);
            chainedOutput.ChainWriter (swOutput);

            monitor.Log.WriteLine ("{0} {1}", command, args);

            var operationMonitor = new AggregatedOperationMonitor (monitor);
            var p = Runtime.ProcessService.StartProcess (command, args, baseDirectory, chainedOutput, chainedError, null);
            operationMonitor.AddOperation (p); //handles cancellation

            p.WaitForOutput ();
            errorOutput = swError.ToString ();
            programOutput = swOutput.ToString ();
            exitCode = p.ExitCode;
            p.Dispose ();

            if (monitor.IsCancelRequested) {
                monitor.Log.WriteLine (GettextCatalog.GetString ("Build cancelled"));
                monitor.ReportError (GettextCatalog.GetString ("Build cancelled"), null);
                if (exitCode == 0)
                    exitCode = -1;
            }
            {
                chainedError.Close ();
                swError.Close ();
                operationMonitor.Dispose ();
            }

            return exitCode;
        }
示例#7
0
		public static void Update (ProjectFile file, bool force)
		{
			ISingleFileCustomTool tool;
			ProjectFile genFile;
			if (!ShouldRunGenerator (file, force, out tool, out genFile)) {
				return;
			}
			
			TaskService.Errors.ClearByOwner (file);
			
			//if this file is already being run, cancel it
			lock (runningTasks) {
				IAsyncOperation runningTask;
				if (runningTasks.TryGetValue (file.FilePath, out runningTask)) {
					runningTask.Cancel ();
					runningTasks.Remove (file.FilePath);
				}
			}
			
			var monitor = IdeApp.Workbench.ProgressMonitors.GetToolOutputProgressMonitor (false);
			var result = new SingleFileCustomToolResult ();
			var aggOp = new AggregatedOperationMonitor (monitor);
			try {
				monitor.BeginTask (GettextCatalog.GetString ("Running generator '{0}' on file '{1}'...", file.Generator, file.Name), 1);
				IAsyncOperation op = tool.Generate (monitor, file, result);
				runningTasks.Add (file.FilePath, op);
				aggOp.AddOperation (op);
				op.Completed += delegate {
					lock (runningTasks) {
						IAsyncOperation runningTask;
						if (runningTasks.TryGetValue (file.FilePath, out runningTask) && runningTask == op) {
							runningTasks.Remove (file.FilePath);
							UpdateCompleted (monitor, aggOp, file, genFile, result, false);
						} else {
							//it was cancelled because another was run for the same file, so just clean up
							aggOp.Dispose ();
							monitor.EndTask ();
							monitor.ReportWarning (GettextCatalog.GetString ("Cancelled because generator ran again for the same file"));
							monitor.Dispose ();
						}
					}
				};
			} catch (Exception ex) {
				result.UnhandledException = ex;
				UpdateCompleted (monitor, aggOp, file, genFile, result, false);
			}
		}
		protected override void OnExecute (IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configSel)
		{
			var conf = (MonoDroidProjectConfiguration) GetConfiguration (configSel);
			
			if (NeedsBuilding (configSel)) {
				monitor.ReportError (
					GettextCatalog.GetString ("MonoDroid projects must be built before uploading"), null);
				return;
			}
			
			var manifestFile = conf.ObjDir.Combine ("android", "AndroidManifest.xml");
			if (!File.Exists (manifestFile)) {
				monitor.ReportError ("Intermediate manifest file is missing", null);
				return;
			}
			
			var manifest = AndroidAppManifest.Load (manifestFile);
			var activity = manifest.GetLaunchableActivityName ();
			if (string.IsNullOrEmpty (activity)) {
				monitor.ReportError ("Application does not contain a launchable activity", null);
				return;
			}
			activity = manifest.PackageName + "/" + activity;
			
			IConsole console = null;
			var opMon = new AggregatedOperationMonitor (monitor);
			try {
				var handler = context.ExecutionHandler as MonoDroidExecutionHandler;
				bool useHandlerDevice = handler != null && handler.DeviceTarget != null;
				
				AndroidDevice device = null;
				
				if (useHandlerDevice) {
					device = handler.DeviceTarget;
				} else {
					var deviceId = GetDeviceTarget (conf);
					if (deviceId != null)
						device = MonoDroidFramework.DeviceManager.GetDevice (deviceId);
					if (device == null)
						SetDeviceTarget (conf, null);
				}
				
				var uploadOp = MonoDroidUtility.SignAndUpload (monitor, this, configSel, false, ref device);
				
				//user cancelled device selection
				if (device == null)
					return;
				
				opMon.AddOperation (uploadOp);
				uploadOp.WaitForCompleted ();
				
				if (!uploadOp.Success || monitor.IsCancelRequested)
					return;
				
				//successful, persist the device choice
				if (!useHandlerDevice)
					SetDeviceTarget (conf, device.ID);
				
				var command = (MonoDroidExecutionCommand) CreateExecutionCommand (configSel, conf);
				command.Device = device;
				command.Activity = activity;
				
				//FIXME: would be nice to skip this if it's a debug handler, which will set another value later
				var propOp = MonoDroidFramework.Toolbox.SetProperty (device, "debug.mono.extra", string.Empty);
				opMon.AddOperation (propOp);
				propOp.WaitForCompleted ();
				if (!propOp.Success) {
					monitor.ReportError (GettextCatalog.GetString ("Count not clear debug settings on device"),
						propOp.Error);
					return;
				}
				
				console = context.ConsoleFactory.CreateConsole (false);
				var executeOp = context.ExecutionHandler.Execute (command, console);
				opMon.AddOperation (executeOp);
				executeOp.WaitForCompleted ();
				
			} finally {
				opMon.Dispose ();
				if (console != null)
					console.Dispose ();
			}
		}
        protected override void OnExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configSel)
        {
            var conf = (MonoBrickProjectConfiguration)GetConfiguration(configSel);
            var cmd = (MonoBrickExecutionCommand)CreateExecutionCommand(configSel, conf);

            bool debugExecution = !(context.ExecutionHandler is MonoBrickExecutionHandler);

            var runtime = conf.TargetRuntime;

            if (runtime.RuntimeId != "Mono" && debugExecution)
            {
                monitor.ReportError("You must use the Mono runtime for debugging!", null);
                return;
            }

            using (var opMon = new AggregatedOperationMonitor(monitor))
            {
                IConsole console = null;

                try
                {
                    console = conf.ExternalConsole
                        ? context.ExternalConsoleFactory.CreateConsole(!conf.PauseConsoleOutput)
                        : context.ConsoleFactory.CreateConsole(!conf.PauseConsoleOutput);

                    cmd.Console = console;

                    if (!MonoBrickUtility.GetEV3Configuration(console))
                    {
                        string configError = "Invalid EV3 configuration. Check Preferences->MonoBrick for correct settings!";

                        console.Log.WriteLine(configError);
                        monitor.ReportError(configError, null);
                        return;
                    }

                    console.Log.WriteLine("Upload to brick...");

                    string EV3IPAddress = UserSettings.Instance.IPAddress;

                    var uploadOp = MonoBrickUtility.Upload(EV3IPAddress, cmd);
                    opMon.AddOperation(uploadOp);

                    uploadOp.WaitForCompleted();

                    if (!uploadOp.Success)
                    {
                        console.Log.WriteLine(uploadOp.ErrorMessage);
                        monitor.ReportError(uploadOp.ErrorMessage, null);
                        return;
                    }

                    console.Log.WriteLine("Running on brick...");

                    var ex = context.ExecutionHandler.Execute(cmd, console);
                    opMon.AddOperation(ex);
                    ex.WaitForCompleted();

                    console.Log.WriteLine("");
                    console.Log.WriteLine("Finished!");
                }
                finally
                {
                    if (console != null)
                        console.Dispose();
                }
            }
        }
        public static void Run(NMEProject project, NMEProjectConfiguration configuration, IProgressMonitor monitor, ExecutionContext context)
        {
            string exe = "haxelib";
            string args = "run nme run " + project.TargetNMMLFile + " " + configuration.Platform.ToLower ();

            if (configuration.DebugMode)
            {
                args += " -debug";
            }

            if (project.AdditionalArguments != "")
            {
                args += " " + project.AdditionalArguments;
            }

            if (configuration.AdditionalArguments != "")
            {
                args += " " + configuration.AdditionalArguments;
            }

            IConsole console;
            if (configuration.ExternalConsole)
                console = context.ExternalConsoleFactory.CreateConsole (false);
            else
                console = context.ConsoleFactory.CreateConsole (false);

            AggregatedOperationMonitor operationMonitor = new AggregatedOperationMonitor (monitor);

            try
            {
                NativeExecutionCommand cmd = new NativeExecutionCommand (exe);
                cmd.Arguments = args;
                cmd.WorkingDirectory = project.BaseDirectory.FullPath;

                if (!context.ExecutionHandler.CanExecute (cmd))
                {
                    monitor.ReportError (String.Format ("Cannot execute '{0} {1}'.", exe, args), null);
                    return;
                }

                IProcessAsyncOperation operation = context.ExecutionHandler.Execute (cmd, console);

                operationMonitor.AddOperation (operation);
                operation.WaitForCompleted ();

                monitor.Log.WriteLine ("Player exited with code {0}.", operation.ExitCode);
            }
            catch (Exception)
            {
                monitor.ReportError (String.Format ("Error while executing '{0} {1}'.", exe, args), null);
            }
            finally
            {
                operationMonitor.Dispose ();
                console.Dispose ();
            }
        }
示例#11
0
		protected override void OnExecute (IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configSel)
		{
			var conf = (MonoDroidProjectConfiguration) GetConfiguration (configSel);
			
			if (NeedsBuilding (configSel)) {
				monitor.ReportError (
					GettextCatalog.GetString ("Mono for Android projects must be built before uploading"), null);
				return;
			}
			
			IConsole console = null;
			var opMon = new AggregatedOperationMonitor (monitor);
			try {
				var handler = context.ExecutionHandler as MonoDroidExecutionHandler;
				bool useHandlerDevice = handler != null && handler.DeviceTarget != null;
				
				AndroidDevice device = null;
				
				if (useHandlerDevice) {
					device = handler.DeviceTarget;
				} else {
					var deviceId = GetDeviceTarget (conf);
					if (deviceId != null)
						device = MonoDroidFramework.DeviceManager.GetDevice (deviceId);
					if (device == null)
						SetDeviceTarget (conf, null);
				}
				
				var uploadOp = MonoDroidUtility.SignAndUpload (monitor, this, configSel, false, ref device);
				
				//user cancelled device selection
				if (device == null)
					return;
				
				opMon.AddOperation (uploadOp);
				uploadOp.WaitForCompleted ();
				
				if (!uploadOp.Success || monitor.IsCancelRequested)
					return;
				
				//get the activity name after signing produced the final manifest
				string activity;
				if (!GetActivityNameFromManifest (monitor, conf, out activity))
					return;

				//successful, persist the device choice
				if (!useHandlerDevice)
					SetDeviceTarget (conf, device.ID);
				
				var command = (MonoDroidExecutionCommand) CreateExecutionCommand (configSel, conf);
				command.Device = device;
				command.Activity = activity;
				
				//FIXME: would be nice to skip this if it's a debug handler, which will set another value later
				var propOp = MonoDroidFramework.Toolbox.SetProperty (device, "debug.mono.extra", string.Empty);
				opMon.AddOperation (propOp);
				propOp.WaitForCompleted ();
				if (!propOp.Success) {
					monitor.ReportError (GettextCatalog.GetString ("Count not clear debug settings on device"),
						propOp.Error);
					return;
				}
				
				console = context.ConsoleFactory.CreateConsole (false);
				var executeOp = context.ExecutionHandler.Execute (command, console);
				opMon.AddOperation (executeOp);
				executeOp.WaitForCompleted ();
				
			} finally {
				opMon.Dispose ();
				if (console != null)
					console.Dispose ();
			}
		}
示例#12
0
		protected override void DoExecute (IProgressMonitor monitor,
		                                   ExecutionContext context)
		{
			CProjectConfiguration conf = (CProjectConfiguration)ActiveConfiguration;
			string command = conf.Output;
			string args = conf.CommandLineParameters;
			string dir = Path.GetFullPath (conf.OutputDirectory);
			string platform = "Native";
			bool pause = conf.PauseConsoleOutput;
			IConsole console;
			
			if (conf.CompileTarget != CBinding.CompileTarget.Bin) {
				IdeApp.Services.MessageService.ShowMessage ("Compile target is not an executable!");
				return;
			}
			
			monitor.Log.WriteLine ("Running project...");
			
			if (conf.ExternalConsole)
				console = context.ExternalConsoleFactory.CreateConsole (!pause);
			else
				console = context.ConsoleFactory.CreateConsole (!pause);
			
			AggregatedOperationMonitor operationMonitor = new AggregatedOperationMonitor (monitor);
			
			try {
				IExecutionHandler handler = context.ExecutionHandlerFactory.CreateExecutionHandler (platform);
				
				if (handler == null) {
					monitor.ReportError ("Cannot execute \"" + command + "\". The selected execution mode is not supported in the " + platform + " platform.", null);
					return;
				}
				
				IProcessAsyncOperation op = handler.Execute (Path.Combine (dir, command), args, dir, console);
				
				operationMonitor.AddOperation (op);
				op.WaitForCompleted ();
				
				monitor.Log.WriteLine ("The operation exited with code: {0}", op.ExitCode);
			} catch (Exception ex) {
				monitor.ReportError ("Cannot execute \"" + command + "\"", ex);
			} finally {			
				operationMonitor.Dispose ();			
				console.Dispose ();
			}
		}
        void ExecuteWithNode(TypeScriptProject project, TypeScriptProjectConfiguration conf, IProgressMonitor monitor, ExecutionContext context)
        {
            if (console != null)
                console.Dispose ();

            var exe = GetNodePath ();

            bool pause = conf.PauseConsoleOutput;

            monitor.Log.WriteLine ("Running project...");

            if (conf.ExternalConsole)
                console = context.ExternalConsoleFactory.CreateConsole (!pause);
            else
                console = context.ConsoleFactory.CreateConsole (!pause);

            AggregatedOperationMonitor operationMonitor = new AggregatedOperationMonitor (monitor);

            try {
                var cmd = CreateExecutionCommand (conf);

                if (!context.ExecutionHandler.CanExecute (cmd)) {
                    monitor.ReportError ("Cannot execute \"" + exe + "\". The selected execution mode is not supported for TypeScript projects.", null);
                    return;
                }

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

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

                monitor.Log.WriteLine ("The operation exited with code: {0}", op.ExitCode);
            } catch (Exception ex) {
                monitor.ReportError ("Cannot execute \"" + exe + "\"", ex);
            } finally {
                operationMonitor.Dispose ();
                console.Dispose ();
            }
        }
示例#14
0
        void DoExecuteWithExe(IProgressMonitor monitor, ExecutionContext context, string exe, HaxeProjectConfiguration configuration)
        {
            monitor.Log.WriteLine("Running project using '{0}' ...", exe);

            if (string.IsNullOrEmpty(exe)) {
                monitor.ReportError(String.Format("No custom player or browser configured."), null);
                return;
            }

            string[] parts = exe.Split(' ');
            string args = "file://"+Path.GetFullPath(Path.Combine(configuration.OutputDirectory, configuration.OutputFileName));
            if (parts.Length > 1)
                args = string.Join(" ", parts, 1, parts.Length-1) + " " + args;
            exe = parts[0];

            IConsole console;
            if (configuration.ExternalConsole)
                console = context.ExternalConsoleFactory.CreateConsole(false);
            else
                console = context.ConsoleFactory.CreateConsole(false);

            AggregatedOperationMonitor operationMonitor = new AggregatedOperationMonitor(monitor);

            try {
                NativeExecutionCommand cmd = new NativeExecutionCommand(exe);
                cmd.Arguments = args;
                cmd.WorkingDirectory = Path.GetFullPath(configuration.OutputDirectory);

                if (!context.ExecutionHandler.CanExecute(cmd)) {
                    monitor.ReportError(String.Format("Cannot execute '{0} {1}'.", exe, args), null);
                    return;
                }

                IProcessAsyncOperation operation = context.ExecutionHandler.Execute(cmd, console);

                operationMonitor.AddOperation(operation);
                operation.WaitForCompleted();

                monitor.Log.WriteLine("Player exited with code {0}.", operation.ExitCode);
            }
            catch (Exception) {
                    monitor.ReportError(String.Format("Error while executing '{0} {1}'.", exe, args), null);
            }
            finally {
                operationMonitor.Dispose();
                console.Dispose();
            }
        }
示例#15
0
		protected override void DoExecute (IProgressMonitor monitor,
		                                   ExecutionContext context,
		                                   ConfigurationSelector configuration)
		{
			PythonConfiguration config;
			IConsole console;
			
			config = (PythonConfiguration) GetConfiguration (configuration);
			
			// Make sure we have a module to execute
			if (config.Runtime == null || String.IsNullOrEmpty (config.Module)) {
				MessageService.ShowMessage ("No target module specified!");
				return;
			}
			
			monitor.Log.WriteLine ("Running project...");
			
			// Create a console, external if needed
			if (config.ExternalConsole) {
				console = context.ExternalConsoleFactory.CreateConsole (!config.PauseConsoleOutput);
			}
			else {
				console = context.ConsoleFactory.CreateConsole (!config.PauseConsoleOutput);
			}
			
			AggregatedOperationMonitor operationMonitor = new AggregatedOperationMonitor (monitor);
			
			try {
				PythonExecutionCommand cmd = new PythonExecutionCommand (config);
				
				if (!context.ExecutionHandler.CanExecute (cmd)) {
					monitor.ReportError ("The selected execution mode is not supported for Python projects.", null);
					return;
				}
				
				IProcessAsyncOperation op = context.ExecutionHandler.Execute (cmd, console);
				operationMonitor.AddOperation (op);
				op.WaitForCompleted ();
				
				monitor.Log.WriteLine ("The operation exited with code: {0}", op.ExitCode);
			}
			catch (Exception ex) {
				monitor.ReportError ("Cannot execute \"" + config.Runtime.Path + "\"", ex);
			}
			finally {
				operationMonitor.Dispose ();
				console.Dispose ();
			}
		}
示例#16
0
		// do this directly instead of relying on the commands handler
		// to stop MD from opening an output pad
		protected override void DoExecute (IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
		{
			var conf = (MoonlightProjectConfiguration) GetConfiguration (configuration);
			
			IConsole console = null;
			
			try {
				// The MoonlightExecutionHandler doesn't output anything to a console, so special-case it
				// Other handlers, like the debug handler, do need a console, so we still need to create one in that case
				// HACK: we can't get the type of the MoonlightExecutionHandler directly, so for now assume that
				// we don't want to show a console for DefaultExecutionHandler
				if (!(context.ExecutionHandler is MoonlightExecutionHandler)
				    && !(context.ExecutionHandler.GetType ().Name == "DefaultExecutionHandler"))
				{
					console = conf.ExternalConsole
						? context.ExternalConsoleFactory.CreateConsole (!conf.PauseConsoleOutput)
						: context.ConsoleFactory.CreateConsole (!conf.PauseConsoleOutput);
				}
				
				var cmd = CreateExecutionCommand (configuration, conf);
				using (var opMon = new AggregatedOperationMonitor (monitor)) {
					var ex = context.ExecutionHandler.Execute (cmd, console);
					opMon.AddOperation (ex);
					ex.WaitForCompleted ();
				}
			} finally {
				if (console != null)
					console.Dispose ();
			}
		}
示例#17
0
		public static void Update (ProjectFile file, bool force)
		{
			var tool = GetGenerator (file);
			if (tool == null)
				return;
			
			ProjectFile genFile = null;
			if (!string.IsNullOrEmpty (file.LastGenOutput))
				genFile = file.Project.Files.GetFile (file.FilePath.ParentDirectory.Combine (file.LastGenOutput));
			
			if (!force && genFile != null && File.Exists (genFile.FilePath) && 
			    File.GetLastWriteTime (file.FilePath) < File.GetLastWriteTime (genFile.FilePath)) {
				return;
			}
			
			TaskService.Errors.ClearByOwner (file);
			
			//if this file is already being run, cancel it
			lock (runningTasks) {
				IAsyncOperation runningTask;
				if (runningTasks.TryGetValue (file.FilePath, out runningTask)) {
					runningTask.Cancel ();
					runningTasks.Remove (file.FilePath);
				}
			}
			
			var monitor = IdeApp.Workbench.ProgressMonitors.GetToolOutputProgressMonitor (false);
			var result = new SingleFileCustomToolResult ();
			var aggOp = new AggregatedOperationMonitor (monitor);
			try {
				monitor.BeginTask (GettextCatalog.GetString ("Running generator '{0}' on file '{1}'...", file.Generator, file.Name), 1);
				var op = tool.Generate (monitor, file, result);
				runningTasks.Add (file.FilePath, op);
				aggOp.AddOperation (op);
				op.Completed += delegate {
					lock (runningTasks) {
						IAsyncOperation runningTask;
						if (runningTasks.TryGetValue (file.FilePath, out runningTask) && runningTask == op) {
							runningTasks.Remove (file.FilePath);
							UpdateCompleted (monitor, aggOp, file, genFile, result);
						} else {
							//it was cancelled because another was run for the same file, so just clean up
							aggOp.Dispose ();
							monitor.EndTask ();
							monitor.ReportWarning (GettextCatalog.GetString ("Cancelled because generator ran again for the same file"));
							monitor.Dispose ();
						}
					}
				};
			} catch (Exception ex) {
				result.UnhandledException = ex;
				UpdateCompleted (monitor, aggOp, file, genFile, result);
			}
		}
示例#18
0
文件: DProject.cs 项目: Geod24/Mono-D
        protected override void DoExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
        {
            bool executeCustomCommand =
                ExtendedConfiguration != null &&
                !string.IsNullOrWhiteSpace(ExtendedConfiguration.RunCommand);

            var conf = GetConfiguration (configuration) as DProjectConfiguration;

            if (conf == null)
                return;

            if (!conf.UnittestMode && (conf.CompileTarget != DCompileTarget.Executable || executeCustomCommand)) {
                MessageService.ShowMessage ("Compile target is not an executable!");
                return;
            }

            bool pause = conf.PauseConsoleOutput;
            IConsole console;

            if (conf.ExternalConsole)
                console = context.ExternalConsoleFactory.CreateConsole (!pause);
            else
                console = context.ConsoleFactory.CreateConsole (!pause);

            monitor.Log.WriteLine("Running project...");

            var operationMonitor = new AggregatedOperationMonitor (monitor);

            try {
                var cmd = CreateExecutionCommand(configuration);
                if (!context.ExecutionHandler.CanExecute (cmd)) {
                    monitor.ReportError ("Cannot execute \"" + conf.Output + "\". The selected execution mode is not supported for D 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 \"" + conf.Output + "\"", ex);
            } finally {
                operationMonitor.Dispose ();
                console.Dispose ();
            }

            if(ProfilerModeHandler.IsProfilerMode && Compiler.HasProfilerSupport)
                IdeApp.CommandService.DispatchCommand( "MonoDevelop.D.Profiler.Commands.ProfilerCommands.AnalyseTaceLog");
        }
		protected void RunFuseCommand (IProgressMonitor monitor, string command, string args)
		{
			LoggingService.LogInfo ("Running FUSE command: {0} {1}", command, args);
			var log = new StringWriter ();
			var psi = new System.Diagnostics.ProcessStartInfo (command, args) {
				RedirectStandardError = true,
				RedirectStandardOutput = true,
				UseShellExecute = false,
			};
			using (var opMon = new AggregatedOperationMonitor (monitor)) {
				using (var pWrapper = MonoDevelop.Core.Runtime.ProcessService.StartProcess (psi, log, log, null)) {
					opMon.AddOperation (pWrapper);
					pWrapper.WaitForOutput ();
					if (pWrapper.ExitCode != 0)
						throw new Exception (log.ToString ());
				}
			}
		}
示例#20
0
		protected override void DoExecute (IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
		{
			//check XSP is available
			
			var cfg = GetConfiguration (configuration);
			var cmd = CreateExecutionCommand (configuration, cfg);
			var browserExcTarget = (BrowserExecutionTarget) context.ExecutionTarget;

			IConsole console = null;
			var operationMonitor = new AggregatedOperationMonitor (monitor);

			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;
					}
				}

				if (cfg.ExternalConsole)
					console = context.ExternalConsoleFactory.CreateConsole (!cfg.PauseConsoleOutput);
				else
					console = context.ConsoleFactory.CreateConsole (!cfg.PauseConsoleOutput);

				// 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 ("Running web server...");
				
				var op = context.ExecutionHandler.Execute (cmd, console);
				operationMonitor.AddOperation (op); //handles cancellation
				
				if (!isXsp) {
					if (browserExcTarget != null)
						browserExcTarget.DesktopApp.Launch (url);
					else
						BrowserLauncher.LaunchDefaultBrowser (url);
				}
				
				op.WaitForCompleted ();
				
				monitor.Log.WriteLine ("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 ("Could not launch web server.", ex);
			} finally {
				operationMonitor.Dispose ();
				if (console != null)
					console.Dispose ();
			}
		}
		//copied from MoonlightBuildExtension
		public static int ExecuteCommand (IProgressMonitor monitor, System.Diagnostics.ProcessStartInfo startInfo, out string errorOutput)
		{
			startInfo.UseShellExecute = false;
			startInfo.RedirectStandardError = true;
			startInfo.RedirectStandardOutput = true;
			
			errorOutput = string.Empty;
			int exitCode = -1;
			
			var swError = new StringWriter ();
			var chainedError = new LogTextWriter ();
			chainedError.ChainWriter (monitor.Log);
			chainedError.ChainWriter (swError);
			
			var operationMonitor = new AggregatedOperationMonitor (monitor);
			
			try {
				var p = Runtime.ProcessService.StartProcess (startInfo, monitor.Log, chainedError, null);
				operationMonitor.AddOperation (p); //handles cancellation
				
				p.WaitForOutput ();
				errorOutput = swError.ToString ();
				exitCode = p.ExitCode;
				p.Dispose ();
				
				if (monitor.IsCancelRequested) {
					monitor.Log.WriteLine (GettextCatalog.GetString ("Build cancelled"));
					monitor.ReportError (GettextCatalog.GetString ("Build cancelled"), null);
					if (exitCode == 0)
						exitCode = -1;
				}
			} finally {
				chainedError.Close ();
				swError.Close ();
				operationMonitor.Dispose ();
			}
			
			return exitCode;
		}
示例#22
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();
			}
		}
示例#23
0
        protected override void DoExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
        {
            var conf = GetConfiguration (configuration) as DProjectConfiguration;

            if (conf == null)
                return;

            bool pause = conf.PauseConsoleOutput;
            IConsole console;

            if (conf.CompileTarget != DCompileTarget.Executable) {
                MessageService.ShowMessage ("Compile target is not an executable!");
                return;
            }

            monitor.Log.WriteLine ("Running project...");

            if (conf.ExternalConsole)
                console = context.ExternalConsoleFactory.CreateConsole (!pause);
            else
                console = context.ConsoleFactory.CreateConsole (!pause);

            var operationMonitor = new AggregatedOperationMonitor (monitor);

            try {
                var cmd = CreateExecutionCommand (conf);
                if (!context.ExecutionHandler.CanExecute (cmd)) {
                    monitor.ReportError ("Cannot execute \"" + conf.Output + "\". The selected execution mode is not supported for D projects.", null);
                    return;
                }

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

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

                monitor.Log.WriteLine ("The operation exited with code: {0}", op.ExitCode);
            } catch (Exception ex) {
                monitor.ReportError ("Cannot execute \"" + conf.Output + "\"", ex);
            } finally {
                operationMonitor.Dispose ();
                console.Dispose ();
            }
        }
示例#24
0
        protected override void DoExecute(IProgressMonitor monitor,
		                                   ExecutionContext context,
		                                   ConfigurationSelector configuration)
        {
            RubyProjectConfiguration conf = (RubyProjectConfiguration)GetConfiguration (configuration);
            bool pause = conf.PauseConsoleOutput;
            IConsole console = (conf.ExternalConsole? context.ExternalConsoleFactory: context.ConsoleFactory).CreateConsole (!pause);
            List<string> loadPaths = new List<string> ();
            loadPaths.Add (BaseDirectory.FullPath);
            foreach (object path in conf.LoadPaths) {
                if (!string.IsNullOrEmpty ((string)path)){ loadPaths.Add ((string)path); }
            }

            ExecutionCommand cmd = new NativeExecutionCommand (RubyLanguageBinding.RubyInterpreter, conf.MainFile, BaseDirectory.FullPath,
                                                               new Dictionary<string,string>(){{"RUBYLIB", string.Join (Path.DirectorySeparatorChar.ToString(), loadPaths.ToArray ()) }});

            monitor.Log.WriteLine ("Running {0} {1}", RubyLanguageBinding.RubyInterpreter, conf.MainFile);

            AggregatedOperationMonitor operationMonitor = new AggregatedOperationMonitor (monitor);

            try {
                if (!context.ExecutionHandler.CanExecute (cmd)) {
                    monitor.ReportError (string.Format ("Cannot execute {0}.", conf.MainFile), null);
                    return;
                }

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

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

                monitor.Log.WriteLine ("The operation exited with code: {0}", op.ExitCode);
            } catch (Exception ex) {
                monitor.ReportError (string.Format ("Cannot execute {0}.", conf.MainFile), ex);
            } finally {
                operationMonitor.Dispose ();
                console.Dispose ();
            }
        }
示例#25
0
		protected override void OnExecute (IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configSel)
		{
			var conf = (IPhoneProjectConfiguration) GetConfiguration (configSel);
			bool isDevice = conf.Platform == PLAT_IPHONE;
			
			if (!Directory.Exists (conf.AppDirectory) || (isDevice && !File.Exists (conf.AppDirectory.Combine ("PkgInfo")))) {
				Gtk.Application.Invoke (delegate {
					MessageService.ShowError (GettextCatalog.GetString ("The application has not been built."));
				});
				return;
			}
			
			if (isDevice) {
				var deviceId = "default";
				if (NeedsUploading (conf, deviceId)) {
					using (var opMon = new AggregatedOperationMonitor (monitor)) {
						using (var op = IPhoneUtility.Upload (TargetRuntime, TargetFramework, conf.AppDirectory)) {
							opMon.AddOperation (op);
							op.WaitForCompleted ();
							if (op.ExitCode != 0)
								return;
						}
						TouchUploadMarker (conf, deviceId);
					}
				}
			}
			
			base.OnExecute (monitor, context, configSel);
		}
示例#26
0
		protected override void OnExecute (IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configSel)
		{
			var conf = (MonoDroidProjectConfiguration) GetConfiguration (configSel);
			
			if (NeedsBuilding (configSel)) {
				monitor.ReportError (
					GettextCatalog.GetString ("MonoDroid projects must be built before uploading"), null);
				return;
			}
			
			var manifestFile = conf.ObjDir.Combine ("android", "AndroidManifest.xml");
			if (!File.Exists (manifestFile)) {
				monitor.ReportError ("Intermediate manifest file is missing", null);
				return;
			}
			
			var manifest = AndroidAppManifest.Load (manifestFile);
			var activity = manifest.GetLaunchableActivityName ();
			if (string.IsNullOrEmpty (activity)) {
				monitor.ReportError ("Application does not contain a launchable activity", null);
				return;
			}
			activity = manifest.PackageName + "/" + activity;
			
			var opMon = new AggregatedOperationMonitor (monitor);
			try {				
				AndroidDevice device;
				var uploadOp = MonoDroidUtility.SignAndUpload (monitor, this, configSel, false, out device);
				opMon.AddOperation (uploadOp);
				uploadOp.WaitForCompleted ();
				if (!uploadOp.Success)
					return;
				
				var command = (MonoDroidExecutionCommand) CreateExecutionCommand (configSel, conf);
				command.Device = device;
				command.Activity = activity;
				
				using (var console = context.ConsoleFactory.CreateConsole (false)) {
					var executeOp = context.ExecutionHandler.Execute (command, console);
					opMon.AddOperation (executeOp);
					executeOp.WaitForCompleted ();
				}
			} finally {
				opMon.Dispose ();
			}
		}
示例#27
0
		protected override void DoExecute (IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
		{
			DotNetProjectConfiguration dotNetProjectConfig = GetConfiguration (configuration) as DotNetProjectConfiguration;
			monitor.Log.WriteLine (GettextCatalog.GetString ("Running {0} ...", dotNetProjectConfig.CompiledOutputName));

			IConsole console = dotNetProjectConfig.ExternalConsole
				? context.ExternalConsoleFactory.CreateConsole (!dotNetProjectConfig.PauseConsoleOutput)
				: context.ConsoleFactory.CreateConsole (!dotNetProjectConfig.PauseConsoleOutput);
			
			AggregatedOperationMonitor aggregatedOperationMonitor = new AggregatedOperationMonitor (monitor);

			try {
				try {
					ExecutionCommand executionCommand = CreateExecutionCommand (configuration, dotNetProjectConfig);
					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;
					}

					IProcessAsyncOperation asyncOp = context.ExecutionHandler.Execute (executionCommand, console);
					aggregatedOperationMonitor.AddOperation (asyncOp);
					asyncOp.WaitForCompleted ();

					monitor.Log.WriteLine (GettextCatalog.GetString ("The application exited with code: {0}", asyncOp.ExitCode));
				} finally {
					console.Dispose ();
					aggregatedOperationMonitor.Dispose ();
				}
			} catch (Exception ex) {
				LoggingService.LogError (string.Format ("Cannot execute \"{0}\"", dotNetProjectConfig.CompiledOutputName), ex);
				monitor.ReportError (GettextCatalog.GetString ("Cannot execute \"{0}\"", dotNetProjectConfig.CompiledOutputName), ex);
			}
		}
示例#28
0
		/// <summary>Executes a build command, writing output to the monitor.</summary>
		/// <returns>Whether the command executed successfully.</returns>
		/// <param name='monitor'>Progress monitor for writing output and handling cancellation.</param>
		/// <param name='startInfo'>Process start info. Redirection will be enabled if necessary.</param>
		/// <param name='stdout'>Text writer for stdout. May be null.</param>
		/// <param name='stderr'>Text writer for stderr. May be null.</param>
		public static int ExecuteBuildCommand (IProgressMonitor monitor, ProcessStartInfo startInfo,
			TextWriter stdout, TextWriter stderr)
		{
			monitor.Log.WriteLine (startInfo.FileName + " " + startInfo.Arguments);
			
			startInfo.UseShellExecute = false;
			startInfo.RedirectStandardError = true;
			startInfo.RedirectStandardOutput = true;
			
			int exitCode = -1;
			
			TextWriter outWriter = monitor.Log, errWriter = monitor.Log;
			LogTextWriter chainedOut = null, chainedErr = null;
			
			if (stdout != null) {
				chainedOut = new LogTextWriter ();
				chainedOut.ChainWriter (outWriter);
				chainedOut.ChainWriter (stdout);
				outWriter = chainedOut;
			}
			
			if (stderr != null) {
				chainedErr = new LogTextWriter ();
				chainedErr.ChainWriter (errWriter);
				chainedErr.ChainWriter (stderr);
				errWriter = chainedErr;
			}
			
			var operationMonitor = new AggregatedOperationMonitor (monitor);
			
			IProcessAsyncOperation p = null;
			try {
				p = Runtime.ProcessService.StartProcess (startInfo, outWriter, errWriter, null);
				operationMonitor.AddOperation (p); //handles cancellation
				p.WaitForCompleted ();
				exitCode = p.ExitCode;
			} finally {
				if (chainedErr != null)
					chainedErr.Dispose ();
				if (chainedOut != null)
					chainedOut.Dispose ();
				if (p != null)
					p.Dispose ();
				operationMonitor.Dispose ();
			}
			
			if (exitCode != 0)
				monitor.Log.WriteLine ("{0} exited with code {1}", Path.GetFileName (startInfo.FileName), exitCode);
			
			return exitCode;
		}