Exemplo n.º 1
0
        //may block while it's showing a GUI. project MUST be built before calling this
        public static MonoDroidUploadOperation SignAndUpload(IProgressMonitor monitor, MonoDroidProject project,
                                                             ConfigurationSelector configSel, bool forceReplace, ref AndroidDevice device)
        {
            var conf  = project.GetConfiguration(configSel);
            var opMon = new AggregatedOperationMonitor(monitor);

            InvokeSynch(() => MonoDroidFramework.EnsureSdksInstalled());

            IAsyncOperation signOp = null;

            if (project.PackageNeedsSigning(configSel))
            {
                ClearUploadFlags(conf);
                signOp = project.SignPackage(configSel);
                opMon.AddOperation(signOp);
            }

            if (device == null)
            {
                device = InvokeSynch(() => ChooseDevice(null));
            }

            if (device == null)
            {
                opMon.Dispose();
                return(null);
            }

            if (!device.IsEmulator && MonoDroidFramework.CheckTrial())
            {
                opMon.Dispose();
                return(null);
            }

            //copture the device for a later anonymous method
            AndroidDevice dev = device;

            bool replaceIfExists = forceReplace || !GetUploadFlag(conf, device);

            var uploadOp = Upload(device, conf.ApkSignedPath, conf.PackageName, signOp, replaceIfExists);

            opMon.AddOperation(uploadOp);
            uploadOp.Completed += delegate(IAsyncOperation op) {
                if (op.Success)
                {
                    SetUploadFlag(conf, dev);
                }
                opMon.Dispose();
            };
            return(uploadOp);
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
        public static MonoDroidPublishOperation PublishPackage(IProgressMonitor monitor, MonoDroidProject project,
                                                               ConfigurationSelector configSel, AndroidSigningOptions options, string sourceApk, string destApk,
                                                               bool createNewKey, string dName, int keyValidity)
        {
            var conf  = project.GetConfiguration(configSel);
            var opMon = new AggregatedOperationMonitor(monitor);

            IAsyncOperation packageOp = null;

            // If we need signing, it means we don't have the apk ready
            if (project.PackageNeedsSigning(configSel))
            {
                ClearUploadFlags(conf);
                packageOp = project.SignPackage(configSel);
                opMon.AddOperation(packageOp);
            }

            var outputMonitor = IdeApp.Workbench.ProgressMonitors.GetOutputProgressMonitor(
                GettextCatalog.GetString("Publishing package"), MonoDevelop.Ide.Gui.Stock.RunProgramIcon, true, true);
            var op = new MonoDroidPublishOperation(outputMonitor, options, sourceApk, destApk, packageOp,
                                                   createNewKey, dName, keyValidity);

            op.Completed += delegate {
                opMon.Dispose();
                outputMonitor.Dispose();
            };
            op.Start();
            return(op);
        }
        internal protected override void OnExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
        {
            ProjectConfiguration conf = (ProjectConfiguration)GetConfiguration(configuration);

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

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

            AggregatedOperationMonitor aggregatedOperationMonitor = new AggregatedOperationMonitor(monitor);

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

                    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) {
                monitor.ReportError(GettextCatalog.GetString("Cannot execute \"{0}\"", FileName), ex);
            }
        }
Exemplo n.º 5
0
        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();
            }
        }
Exemplo n.º 6
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();
            }
        }
Exemplo n.º 7
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 (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();
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Executes a file and reports events related to the execution to the 'monitor' passed in the parameters.
        /// </summary>
        public 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);
        }
Exemplo n.º 9
0
        protected override void DoExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector config)
        {
            //check XSP is available

            var configuration = (AspNetAppProjectConfiguration)GetConfiguration(config);
            var cmd           = CreateExecutionCommand(config, configuration);

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

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

                string url = String.Format("http://{0}:{1}", this.XspParameters.Address, this.XspParameters.Port);

                bool isXsp = true;                 //FIXME: fix this when it might not be true

                if (isXsp)
                {
                    console = new XspBrowserLauncherConsole(console, delegate {
                        BrowserLauncher.LaunchDefaultBrowser(url);
                    });
                }

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

                var op = context.ExecutionHandler.Execute(cmd, console);
                operationMonitor.AddOperation(op);                  //handles cancellation

                if (!isXsp)
                {
                    BrowserLauncher.LaunchDefaultBrowser(url);
                }

                op.WaitForCompleted();

                monitor.Log.WriteLine("The web server exited with code: {0}", op.ExitCode);
            } catch (Exception ex) {
                monitor.ReportError("Could not launch web server.", ex);
            } finally {
                operationMonitor.Dispose();
                if (console != null)
                {
                    console.Dispose();
                }
            }
        }
Exemplo n.º 10
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);
            }
        }
Exemplo n.º 11
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();
            }
        }
Exemplo n.º 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();
            }
        }
Exemplo n.º 13
0
        public static IAsyncOperation SignAndCopy(IProgressMonitor monitor, MonoDroidProject project,
                                                  ConfigurationSelector configSel)
        {
            var conf  = project.GetConfiguration(configSel);
            var opMon = new AggregatedOperationMonitor(monitor);

            IAsyncOperation signOp = null;

            if (project.PackageNeedsSigning(configSel))
            {
                ClearUploadFlags(conf);
                signOp = project.SignPackage(configSel);
                opMon.AddOperation(signOp);
            }

            string packageName = project.GetPackageName(conf);
            string targetFile  = InvokeSynch(() => ChooseApkLocation(null, project.BaseDirectory, packageName));

            if (String.IsNullOrEmpty(targetFile))
            {
                opMon.Dispose();
                return(null);
            }

            if (MonoDroidFramework.CheckTrial())
            {
                opMon.Dispose();
                return(null);
            }

            var copy = CopyApk(signOp, conf.ApkSignedPath, targetFile);

            copy.Completed += delegate {
                opMon.Dispose();
            };

            return(copy);
        }
Exemplo n.º 14
0
        public static void Run(HaxeProject project, HaxeProjectConfiguration configuration, IProgressMonitor monitor, ExecutionContext context)
        {
            ExecutionCommand cmd = CreateExecutionCommand(project, configuration);

            if (cmd is HaxeExecutionCommand)
            {
                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.Target), 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.Target), null);
                }
                finally
                {
                    operationMonitor.Dispose();
                    console.Dispose();
                }
            }
            //else
            //{
            //	Process.Start (cmd);
            //}
        }
Exemplo n.º 15
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();
            }
        }
Exemplo n.º 16
0
        //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);
        }
Exemplo n.º 17
0
        public static IAsyncOperation Sign(IProgressMonitor monitor, MonoDroidProject project, ConfigurationSelector configSel)
        {
            var conf  = project.GetConfiguration(configSel);
            var opMon = new AggregatedOperationMonitor(monitor);

            InvokeSynch(() => MonoDroidFramework.EnsureSdksInstalled());

            IAsyncOperation signOp = null;

            if (project.PackageNeedsSigning(configSel))
            {
                ClearUploadFlags(conf);
                signOp            = project.SignPackage(configSel);
                signOp.Completed += delegate {
                    opMon.Dispose();
                };
                return(signOp);
            }

            return(Core.Execution.NullProcessAsyncOperation.Success);
        }
Exemplo n.º 18
0
        static bool UpdateCompleted(IProgressMonitor monitor, AggregatedOperationMonitor aggOp,
                                    ProjectFile file, ProjectFile genFile, SingleFileCustomToolResult result,
                                    bool runMultipleFiles)
        {
            monitor.EndTask();
            if (aggOp != null)
            {
                aggOp.Dispose();
            }

            if (monitor.IsCancelRequested)
            {
                monitor.ReportError(GettextCatalog.GetString("Cancelled"), null);
                monitor.Dispose();
                return(false);
            }

            string genFileName;

            try {
                bool broken = false;

                if (result.UnhandledException != null)
                {
                    broken = true;
                    string msg = GettextCatalog.GetString("The '{0}' code generator crashed", file.Generator);
                    result.Errors.Add(new CompilerError(file.Name, 0, 0, "", msg + ": " + result.UnhandledException.Message));
                    monitor.ReportError(msg, result.UnhandledException);
                    LoggingService.LogError(msg, result.UnhandledException);
                }

                genFileName = result.GeneratedFilePath.IsNullOrEmpty?
                              null : result.GeneratedFilePath.ToRelative(file.FilePath.ParentDirectory);

                if (!string.IsNullOrEmpty(genFileName))
                {
                    bool validName = genFileName.IndexOfAny(new [] { '/', '\\' }) < 0 &&
                                     FileService.IsValidFileName(genFileName);

                    if (!broken && !validName)
                    {
                        broken = true;
                        string msg = GettextCatalog.GetString("The '{0}' code generator output invalid filename '{1}'",
                                                              file.Generator, result.GeneratedFilePath);
                        result.Errors.Add(new CompilerError(file.Name, 0, 0, "", msg));
                        monitor.ReportError(msg, null);
                    }
                }

                if (result.Errors.Count > 0)
                {
                    DispatchService.GuiDispatch(delegate {
                        foreach (CompilerError err in result.Errors)
                        {
                            TaskService.Errors.Add(new Task(file.FilePath, err.ErrorText, err.Column, err.Line,
                                                            err.IsWarning? TaskSeverity.Warning : TaskSeverity.Error,
                                                            TaskPriority.Normal, file.Project.ParentSolution, file));
                        }
                    });
                }

                if (broken)
                {
                    return(true);
                }

                if (!runMultipleFiles)
                {
                    if (result.Success)
                    {
                        monitor.ReportSuccess("Generated file successfully.");
                    }
                    else if (result.SuccessWithWarnings)
                    {
                        monitor.ReportSuccess("Warnings in file generation.");
                    }
                    else
                    {
                        monitor.ReportError("Errors in file generation.", null);
                    }
                }
            } finally {
                if (!runMultipleFiles)
                {
                    monitor.Dispose();
                }
            }

            if (result.GeneratedFilePath.IsNullOrEmpty || !File.Exists(result.GeneratedFilePath))
            {
                return(true);
            }

            // broadcast a change event so text editors etc reload the file
            FileService.NotifyFileChanged(result.GeneratedFilePath);

            // add file to project, update file properties, etc
            Gtk.Application.Invoke(delegate {
                bool projectChanged = false;
                if (genFile == null)
                {
                    genFile        = file.Project.AddFile(result.GeneratedFilePath, result.OverrideBuildAction);
                    projectChanged = true;
                }
                else if (result.GeneratedFilePath != genFile.FilePath)
                {
                    genFile.Name   = result.GeneratedFilePath;
                    projectChanged = true;
                }

                if (file.LastGenOutput != genFileName)
                {
                    file.LastGenOutput = genFileName;
                    projectChanged     = true;
                }

                if (genFile.DependsOn != file.FilePath.FileName)
                {
                    genFile.DependsOn = file.FilePath.FileName;
                    projectChanged    = true;
                }

                if (projectChanged)
                {
                    IdeApp.ProjectOperations.Save(file.Project);
                }
            });

            return(true);
        }
Exemplo n.º 19
0
        protected override void Run()
        {
            var proj = DefaultUploadToDeviceHandler.GetActiveExecutableIPhoneProject();
            var conf = (IPhoneProjectConfiguration)proj.GetConfiguration(IdeApp.Workspace.ActiveConfiguration);

            IdeApp.ProjectOperations.Build(proj).Completed += delegate(IAsyncOperation op) {
                if (!op.Success)
                {
                    MessageService.ShowError(
                        GettextCatalog.GetString("Cannot zip app bundle"),
                        GettextCatalog.GetString("Project did not build successfully"));
                    return;
                }

                var dlg = new MonoDevelop.Components.SelectFileDialog(
                    GettextCatalog.GetString("Save zipped app bundle"), Gtk.FileChooserAction.Save);
                dlg.InitialFileName = string.Format("{0}-{1}.zip", conf.CompiledOutputName.FileNameWithoutExtension, proj.BundleVersion);
                dlg.DefaultFilter   = dlg.AddFilter("Zip file", "*.zip");

                if (!dlg.Run())
                {
                    return;
                }

                var zipFile = dlg.SelectedFile;
                var builder = new ProcessArgumentBuilder();
                builder.Add("-r", "-y");
                builder.AddQuoted(zipFile);
                builder.AddQuoted(conf.AppDirectory.FileName);
                var cmd = builder.ToString();
                var workingDirectory = conf.AppDirectory.ParentDirectory;

                new System.Threading.Thread(delegate() {
                    IProgressMonitor monitor         = null;
                    AggregatedOperationMonitor opMon = null;
                    IProcessAsyncOperation procOp    = null;

                    try {
                        monitor = IdeApp.Workbench.ProgressMonitors.GetOutputProgressMonitor(
                            GettextCatalog.GetString("Zip App Bundle"), MonoDevelop.Ide.Gui.Stock.RunProgramIcon, true, true);
                        monitor.BeginTask(GettextCatalog.GetString("Zipping app bundle"), 0);

                        var console = (IConsole)monitor;
                        console.Log.WriteLine("zip " + cmd);

                        //don't use StartConsoleProcess, it disposes the pad
                        procOp = Runtime.ProcessService.StartProcess(
                            "zip", cmd, workingDirectory, console.Out, console.Error, null);
                        opMon = new AggregatedOperationMonitor(monitor, procOp);

                        procOp.WaitForCompleted();

                        monitor.EndTask();

                        if (procOp.ExitCode != 0)
                        {
                            monitor.ReportError(GettextCatalog.GetString("Failed to zip app"), null);
                        }
                        else
                        {
                            monitor.ReportSuccess(GettextCatalog.GetString("Saved zipped app to '{0}'", zipFile));
                        }
                    } catch (Exception ex) {
                        LoggingService.LogError("Error in app zipper", ex);
                        //be super-safe, crashing thread crashes whole app
                        try {
                            monitor.ReportError("App zipping failed", ex);
                        } catch {}
                    }
                    if (opMon != null)
                    {
                        opMon.Dispose();
                    }
                    if (procOp != null)
                    {
                        procOp.Dispose();
                    }
                    if (monitor != null)
                    {
                        monitor.Dispose();
                    }
                }).Start();
            };
        }
Exemplo n.º 20
0
        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");
            }
        }
Exemplo n.º 21
0
        protected override void DoExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector config)
        {
            //check XSP is available

            var configuration = (AspNetAppProjectConfiguration)GetConfiguration(config);
            var cmd           = CreateExecutionCommand(config, configuration);

            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 (configuration.ExternalConsole)
                {
                    console = context.ExternalConsoleFactory.CreateConsole(!configuration.PauseConsoleOutput);
                }
                else
                {
                    console = context.ConsoleFactory.CreateConsole(!configuration.PauseConsoleOutput);
                }

                string url = String.Format("http://{0}:{1}", this.XspParameters.Address, this.XspParameters.Port);


                if (isXsp)
                {
                    console = new XspBrowserLauncherConsole(console, delegate {
                        BrowserLauncher.LaunchDefaultBrowser(url);
                    });
                }

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

                var op = context.ExecutionHandler.Execute(cmd, console);
                operationMonitor.AddOperation(op);                  //handles cancellation

                if (!isXsp)
                {
                    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();
                }
            }
        }
Exemplo n.º 22
0
        public void Execute(IProgressMonitor monitor, IWorkspaceObject entry, ExecutionContext context,
                            ConfigurationSelector configuration)
        {
            ProcessExecutionCommand cmd = CreateExecutionCommand(entry, configuration);

            monitor.Log.WriteLine(GettextCatalog.GetString("Executing: {0} {1}", cmd.Command, cmd.Arguments));

            if (!Directory.Exists(cmd.WorkingDirectory))
            {
                monitor.ReportError(GettextCatalog.GetString("Custom command working directory does not exist"), null);
                return;
            }

            AggregatedOperationMonitor aggMon = null;
            IProcessAsyncOperation     oper   = null;
            IConsole console = null;

            try {
                if (context != null)
                {
                    if (externalConsole)
                    {
                        console = context.ExternalConsoleFactory.CreateConsole(!pauseExternalConsole);
                    }
                    else
                    {
                        console = context.ConsoleFactory.CreateConsole(!pauseExternalConsole);
                    }
                    oper = context.ExecutionHandler.Execute(cmd, console);
                }
                else
                {
                    if (externalConsole)
                    {
                        console = ExternalConsoleFactory.Instance.CreateConsole(!pauseExternalConsole);
                        oper    = Runtime.ProcessService.StartConsoleProcess(cmd.Command, cmd.Arguments,
                                                                             cmd.WorkingDirectory, console, null);
                    }
                    else
                    {
                        oper = Runtime.ProcessService.StartProcess(cmd.Command, cmd.Arguments,
                                                                   cmd.WorkingDirectory, monitor.Log, monitor.Log, null, false);
                    }
                }
                aggMon = new AggregatedOperationMonitor(monitor, oper);
                oper.WaitForCompleted();
                if (!oper.Success)
                {
                    monitor.ReportError("Custom command failed (exit code: " + oper.ExitCode + ")", null);
                }
            } catch (Win32Exception w32ex) {
                monitor.ReportError(GettextCatalog.GetString("Failed to execute custom command '{0}': {1}",
                                                             cmd.Command, w32ex.Message), null);
                return;
            } catch (Exception ex) {
                LoggingService.LogError("Command execution failed", ex);
                throw new UserException(GettextCatalog.GetString("Command execution failed: {0}", ex.Message));
            } finally {
                if (oper == null || !oper.Success)
                {
                    monitor.AsyncOperation.Cancel();
                }
                if (oper != null)
                {
                    oper.Dispose();
                }
                if (console != null)
                {
                    console.Dispose();
                }
                if (aggMon != null)
                {
                    aggMon.Dispose();
                }
            }
        }
Exemplo n.º 23
0
        protected override void DoExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
        {
            if (!CheckCanExecute(configuration))
            {
                return;
            }

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

            var aggregatedMonitor = new AggregatedOperationMonitor(monitor);

            try {
                string param;

                if (config.LangVersion != LangVersion.Love)
                {
                    param = string.Format("\"{0}\" {1}", config.MainFile, config.CommandLineParameters);
                }
                else
                {
                    param = string.Format("\"{0}\" {1}", ItemDirectory, config.CommandLineParameters);
                }

                IProcessAsyncOperation op =
                    Runtime.ProcessService.StartConsoleProcess(GetLuaPath(config),
                                                               param, (config.LangVersion != LangVersion.Love) ? BaseDirectory : ItemDirectory,
                                                               config.EnvironmentVariables, console, null);

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

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

                /*
                 * var executionCommand = //CreateExecutionCommand( configuration, config );
                 *      new NativeExecutionCommand( GetLuaPath( config.LangVersion ),
                 *                                 config.CommandLineParameters,
                 *                                 BaseDirectory );
                 *
                 *
                 * if( !context.ExecutionHandler.CanExecute( executionCommand ) )
                 * {
                 *      monitor.ReportError( GettextCatalog.GetString( "Cannot execute application. The selected execution mode " +
                 *      "is not supported for Lua projects" ), null );
                 *      return;
                 * }
                 *
                 * IProcessAsyncOperation 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.MainFile), exc);
            } finally {
                console.Dispose();
                aggregatedMonitor.Dispose();
            }
        }
Exemplo n.º 24
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);
        }
Exemplo n.º 25
0
        protected override void OnExecute(IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configSel)
        {
            var conf = (MonoDroidProjectConfiguration)GetConfiguration(configSel);

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

                if (!device.IsEmulator && MonoDroidFramework.CheckTrial())
                {
                    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("Could 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();
                }
            }
        }
        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);
            }
        }
        static void UpdateCompleted(IProgressMonitor monitor, AggregatedOperationMonitor aggOp,
                                    ProjectFile file, ProjectFile genFile, SingleFileCustomToolResult result)
        {
            monitor.EndTask();
            aggOp.Dispose();

            if (monitor.IsCancelRequested)
            {
                monitor.ReportError(GettextCatalog.GetString("Cancelled"), null);
                monitor.Dispose();
                return;
            }

            string genFileName;

            try
            {
                bool broken = false;

                if (result.UnhandledException != null)
                {
                    broken = true;
                    string msg = GettextCatalog.GetString("The '{0}' code generator crashed", file.Generator);
                    result.Errors.Add(new CompilerError(file.Name, 0, 0, "", msg + ": " + result.UnhandledException.Message));
                    monitor.ReportError(msg, result.UnhandledException);
                    LoggingService.LogError(msg, result.UnhandledException);
                }

                genFileName = result.GeneratedFilePath.IsNullOrEmpty?
                              null : result.GeneratedFilePath.ToRelative(file.FilePath.ParentDirectory);

                bool validName = !string.IsNullOrEmpty(genFileName) &&
                                 genFileName.IndexOfAny(new char[] { '/', '\\' }) < 0 &&
                                 FileService.IsValidFileName(genFileName);

                if (!broken && !validName)
                {
                    broken = true;
                    string msg = GettextCatalog.GetString("The '{0}' code generator output invalid filename '{1}'",
                                                          file.Generator, result.GeneratedFilePath);
                    result.Errors.Add(new CompilerError(file.Name, 0, 0, "", msg));
                    monitor.ReportError(msg, null);
                }

                if (result.Errors.Count > 0)
                {
                    foreach (CompilerError err in result.Errors)
                    {
                        TaskService.Errors.Add(new Task(file.FilePath, err.ErrorText, err.Column, err.Line,
                                                        err.IsWarning? TaskSeverity.Warning : TaskSeverity.Error,
                                                        TaskPriority.Normal, file.Project.ParentSolution, file));
                    }
                }

                if (broken)
                {
                    return;
                }

                if (result.Success)
                {
                    monitor.ReportSuccess("Generated file successfully.");
                }
                else
                {
                    monitor.ReportError("Failed to generate file. See error pad for details.", null);
                }
            }
            finally
            {
                monitor.Dispose();
            }

            if (!result.GeneratedFilePath.IsNullOrEmpty && File.Exists(result.GeneratedFilePath))
            {
                Gtk.Application.Invoke(delegate
                {
                    if (genFile == null)
                    {
                        genFile = file.Project.AddFile(result.GeneratedFilePath);
                    }
                    else if (result.GeneratedFilePath != genFile.FilePath)
                    {
                        genFile.Name = result.GeneratedFilePath;
                    }
                    file.LastGenOutput = genFileName;
                    genFile.DependsOn  = file.FilePath.FileName;

                    IdeApp.ProjectOperations.Save(file.Project);
                });
            }
        }