MonoDevelop.D.Projects.Dub.DubProject.CreateExecutionCommand C# (CSharp) Méthode

CreateExecutionCommand() public méthode

public CreateExecutionCommand ( MonoDevelop.Projects.ConfigurationSelector conf ) : MonoDevelop.Core.Execution.NativeExecutionCommand
conf MonoDevelop.Projects.ConfigurationSelector
Résultat MonoDevelop.Core.Execution.NativeExecutionCommand
        public override NativeExecutionCommand CreateExecutionCommand(ConfigurationSelector conf)
        {
            var sr = new StringBuilder();
            DubBuilder.Instance.BuildProgramArgAppendix(sr, this, GetConfiguration(conf) as DubProjectConfiguration);

            var cmd = base.CreateExecutionCommand(conf);

            cmd.Arguments = sr.ToString();
            cmd.WorkingDirectory = BaseDirectory;
            return cmd;
        }

Usage Example

Exemple #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();
            }
        }
All Usage Examples Of MonoDevelop.D.Projects.Dub.DubProject::CreateExecutionCommand