Ejemplo n.º 1
0
        public static ProgressMonitor GetMonitor(bool ignoreLogMessages)
        {
            ConsoleProgressMonitor m = new ConsoleProgressMonitor();

            m.IgnoreLogMessages = ignoreLogMessages;
            return(m);
        }
Ejemplo n.º 2
0
        public static ProgressMonitor GetMonitor()
        {
            ConsoleProgressMonitor m = new ConsoleProgressMonitor();

            m.IgnoreLogMessages = true;
            return(m);
        }
Ejemplo n.º 3
0
        public static void Run()
        {
            IProgressMonitor monitor = new ConsoleProgressMonitor();

            CocoStudio.Core.View.Workbench workbench = new CocoStudio.Core.View.Workbench();
            workbench.Initialize(monitor);
            workbench.Show("Cocos Studio");
        }
Ejemplo n.º 4
0
        public static bool SupportsProjectType(string projectFile)
        {
            if (!string.IsNullOrWhiteSpace(projectFile))
            {
                // If we have a project file, try to load it.
                try {
                    using (var monitor = new ConsoleProgressMonitor()) {
                        return(MSBuildProjectService.LoadItem(monitor, projectFile, null, null, null) != null);
                    }
                } catch {
                    return(false);
                }
            }

            return(false);
        }
Ejemplo n.º 5
0
 protected override void OnDestroyed()
 {
     isDestroyed = true;
     MessageService.PopupDialog -= HandlePopupDialog;
     base.OnDestroyed();
     if (bitmap != null)
     {
         bitmap.Dispose();
         bitmap = null;
     }
     if (monitor != null)
     {
         monitor.Dispose();
         monitor = null;
     }
 }
Ejemplo n.º 6
0
        public async Task <int> Run(string[] arguments)
        {
            DesktopService.Initialize();

            Console.WriteLine(BrandingService.BrandApplicationName("MonoDevelop Gettext Update Tool"));
            foreach (string s in arguments)
            {
                ReadArgument(s);
            }

            if (help)
            {
                Console.WriteLine("gettext-update [options] [project-file]");
                Console.WriteLine("--f --file:FILE   Project or solution file to build.");
                Console.WriteLine("--p --project:PROJECT  Name of the project to build.");
                Console.WriteLine("--sort  Sorts the output po file");
                Console.WriteLine();
                return(0);
            }

            if (file == null)
            {
                var files = Directory.EnumerateFiles(".");
                foreach (string f in files)
                {
                    if (Services.ProjectService.IsWorkspaceItemFile(f))
                    {
                        file = f;
                        break;
                    }
                }
                if (file == null)
                {
                    Console.WriteLine("Solution file not found.");
                    return(1);
                }
            }
            else if (!Services.ProjectService.IsWorkspaceItemFile(file))
            {
                Console.WriteLine("File '{0}' is not a project or solution.", file);
                return(1);
            }

            ConsoleProgressMonitor monitor = new ConsoleProgressMonitor();

            monitor.IgnoreLogMessages = true;

            WorkspaceItem centry = await Services.ProjectService.ReadWorkspaceItem(monitor, file);

            monitor.IgnoreLogMessages = false;

            Solution solution = centry as Solution;

            if (solution == null)
            {
                Console.WriteLine("File is not a solution: " + file);
                return(1);
            }

            if (project != null)
            {
                SolutionItem item = solution.FindProjectByName(project);

                if (item == null)
                {
                    Console.WriteLine("The project '" + project + "' could not be found in " + file);
                    return(1);
                }
                TranslationProject tp = item as TranslationProject;
                if (tp == null)
                {
                    Console.WriteLine("The project '" + item.FileName + "' is not a translation project");
                    return(1);
                }
                tp.UpdateTranslations(monitor, sort);
            }
            else
            {
                foreach (TranslationProject p in solution.GetAllItems <TranslationProject>())
                {
                    p.UpdateTranslations(monitor, sort);
                }
            }

            return(0);
        }
Ejemplo n.º 7
0
        public int Run(string[] arguments)
        {
            Console.WriteLine("MonoDevelop Build Tool");
            foreach (string s in arguments)
            {
                ReadArgument(s);
            }

            if (help)
            {
                Console.WriteLine("build [options] [build-file]");
                Console.WriteLine("-p --project:PROJECT  Name of the project to build.");
                Console.WriteLine("-t --target:TARGET    Name of the target: Build or Clean.");
                Console.WriteLine("-c --configuration:CONFIGURATION  Name of the solution configuration to build.");
                Console.WriteLine();
                Console.WriteLine("Supported targets:");
                Console.WriteLine("  {0}: build the project (the default target).", ProjectService.BuildTarget);
                Console.WriteLine("  {0}: clean the project.", ProjectService.CleanTarget);
                Console.WriteLine();
                return(0);
            }

            string solFile  = null;
            string itemFile = null;

            if (file == null)
            {
                string[] files = Directory.GetFiles(".");
                foreach (string f in files)
                {
                    if (Services.ProjectService.IsWorkspaceItemFile(f))
                    {
                        solFile = f;
                        break;
                    }
                    else if (itemFile == null && Services.ProjectService.IsSolutionItemFile(f))
                    {
                        itemFile = f;
                    }
                }
                if (solFile == null && itemFile == null)
                {
                    Console.WriteLine("Project file not found.");
                    return(1);
                }
            }
            else
            {
                if (Services.ProjectService.IsWorkspaceItemFile(file))
                {
                    solFile = file;
                }
                else if (Services.ProjectService.IsSolutionItemFile(file))
                {
                    itemFile = file;
                }
                else
                {
                    Console.WriteLine("File '{0}' is not a project or solution.", file);
                    return(1);
                }
            }

            ConsoleProgressMonitor monitor = new ConsoleProgressMonitor();

            IBuildTarget item;

            if (solFile != null)
            {
                item = Services.ProjectService.ReadWorkspaceItem(monitor, solFile);
            }
            else
            {
                item = Services.ProjectService.ReadSolutionItem(monitor, itemFile);
            }

            if (project != null)
            {
                Solution solution = item as Solution;
                item = null;

                if (solution != null)
                {
                    item = solution.FindProjectByName(project);
                }
                if (item == null)
                {
                    Console.WriteLine("The project '" + project + "' could not be found in " + file);
                    return(1);
                }
            }

            IConfigurationTarget configTarget = item as IConfigurationTarget;

            if (config == null && configTarget != null)
            {
                config = configTarget.DefaultConfigurationId;
            }

            ConfigurationSelector configuration;

            if (item is SolutionEntityItem)
            {
                configuration = new ItemConfigurationSelector(config);
            }
            else
            {
                configuration = new SolutionConfigurationSelector(config);
            }

            monitor = new ConsoleProgressMonitor();
            BuildResult res = item.RunTarget(monitor, command, configuration);

            return((res == null || res.ErrorCount == 0) ? 0 : 1);
        }
Ejemplo n.º 8
0
        public async Task <int> Run(string[] arguments)
        {
            if (arguments.Length == 0 || arguments [0] == "--help")
            {
                Console.WriteLine("");
                Console.WriteLine("Project Export Tool");
                Console.WriteLine("Usage: mdtool project-export <source-project-file> [-d:dest-path] [-f:format-name]");
                Console.WriteLine("");
                Console.WriteLine("Options");
                Console.WriteLine("  -d:<dest-path>      Directory where the project will be exported.");
                Console.WriteLine("  -f:\"<format-name>\"  Format to which export the project or solution.");
                Console.WriteLine("  -l                  Show a list of all allowed target formats.");
                Console.WriteLine("  -p:<project-name>   When exporting a solution, name of a project to be");
                Console.WriteLine("                      included in the export. It can be specified multiple");
                Console.WriteLine("                      times.");
                Console.WriteLine("");
                Console.WriteLine("  The format name is optional. A list of allowed file formats will be");
                Console.WriteLine("  shown if none is provided.");
                Console.WriteLine("");
                return(0);
            }

            string        projectFile = null;
            string        destPath    = null;
            string        formatName  = null;
            bool          formatList  = false;
            List <string> projects    = new List <string> ();

            string[] itemsToExport = null;

            foreach (string s in arguments)
            {
                if (s.StartsWith("-d:"))
                {
                    destPath = s.Substring(3);
                }
                else if (s.StartsWith("-f:"))
                {
                    formatName = s.Substring(3);
                }
                else if (s.StartsWith("-p:"))
                {
                    projects.Add(s.Substring(3));
                }
                else if (s == "-l")
                {
                    formatList = true;
                }
                else if (projectFile != null)
                {
                    Console.WriteLine("Only one project can be converted at a time.");
                    return(1);
                }
                else
                {
                    projectFile = s;
                }
            }

            if (projectFile == null)
            {
                Console.WriteLine("Project or solution file name not provided.");
                return(1);
            }

            projectFile = FileService.GetFullPath(projectFile);
            if (!File.Exists(projectFile))
            {
                Console.WriteLine("File {0} not found.", projectFile);
                return(1);
            }

            ConsoleProgressMonitor monitor = new ConsoleProgressMonitor();

            monitor.IgnoreLogMessages = true;


            object item;

            if (Services.ProjectService.IsWorkspaceItemFile(projectFile))
            {
                item = await Services.ProjectService.ReadWorkspaceItem(monitor, projectFile);

                if (projects.Count > 0)
                {
                    Solution sol = item as Solution;
                    if (sol == null)
                    {
                        Console.WriteLine("The -p option can only be used when exporting a solution.");
                        return(1);
                    }
                    for (int n = 0; n < projects.Count; n++)
                    {
                        string pname = projects [n];
                        if (pname.Length == 0)
                        {
                            Console.WriteLine("Project name not specified in -p option.");
                            return(1);
                        }
                        Project p = sol.FindProjectByName(pname);
                        if (p == null)
                        {
                            Console.WriteLine("Project '" + pname + "' not found in solution.");
                            return(1);
                        }
                        projects[n] = p.ItemId;
                    }
                    itemsToExport = projects.ToArray();
                }
            }
            else
            {
                if (projects.Count > 0)
                {
                    Console.WriteLine("The -p option can't be used when exporting a single project");
                    return(1);
                }
                item = await Services.ProjectService.ReadSolutionItem(monitor, projectFile);
            }

            var formats = MSBuildFileFormat.GetSupportedFormats().ToArray();

            if (formats.Length == 0)
            {
                Console.WriteLine("Can't convert file to any format: " + projectFile);
                return(1);
            }

            MSBuildFileFormat format = null;

            if (formatName == null || formatList)
            {
                Console.WriteLine();
                Console.WriteLine("Target formats:");
                for (int n = 0; n < formats.Length; n++)
                {
                    Console.WriteLine("  {0}. {1}", n + 1, formats [n].Name);
                }
                Console.WriteLine();
                if (formatList)
                {
                    return(0);
                }

                int op = 0;
                do
                {
                    Console.Write("Convert to format: ");
                    string s = Console.ReadLine();
                    if (s.Length == 0)
                    {
                        return(1);
                    }
                    if (int.TryParse(s, out op))
                    {
                        if (op > 0 && op <= formats.Length)
                        {
                            break;
                        }
                    }
                } while (true);

                format = formats [op - 1];
            }
            else
            {
                foreach (var f in formats)
                {
                    if (f.Name == formatName)
                    {
                        format = f;
                    }
                }
                if (format == null)
                {
                    Console.WriteLine("Unknown file format: " + formatName);
                    return(1);
                }
            }

            if (destPath == null)
            {
                destPath = Path.GetDirectoryName(projectFile);
            }
            destPath = FileService.GetFullPath(destPath);

            string ofile = await Services.ProjectService.Export(monitor, projectFile, itemsToExport, destPath, format);

            if (ofile != null)
            {
                Console.WriteLine("Saved file: " + ofile);
                return(0);
            }
            else
            {
                Console.WriteLine("Project export failed.");
                return(1);
            }
        }
Ejemplo n.º 9
0
        public int Run(string[] arguments)
        {
            Console.WriteLine(BrandingService.BrandApplicationName("MonoDevelop Build Tool"));
            foreach (string s in arguments)
            {
                ReadArgument(s);
            }

            if (help)
            {
                Console.WriteLine("build [options] [build-file]");
                Console.WriteLine("-p --project:PROJECT  Name of the project to build.");
                Console.WriteLine("-t --target:TARGET    Name of the target: Build or Clean.");
                Console.WriteLine("-c --configuration:CONFIGURATION  Name of the solution configuration to build.");
                Console.WriteLine("-r --runtime:PREFIX   Prefix of the Mono runtime to build against.");
                Console.WriteLine();
                Console.WriteLine("Supported targets:");
                Console.WriteLine("  {0}: build the project (the default target).", ProjectService.BuildTarget);
                Console.WriteLine("  {0}: clean the project.", ProjectService.CleanTarget);
                Console.WriteLine();
                return(0);
            }

            string solFile  = null;
            string itemFile = null;

            if (file == null)
            {
                string[] files = Directory.GetFiles(".");
                foreach (string f in files)
                {
                    if (Services.ProjectService.IsWorkspaceItemFile(f))
                    {
                        solFile = f;
                        break;
                    }
                    else if (itemFile == null && Services.ProjectService.IsSolutionItemFile(f))
                    {
                        itemFile = f;
                    }
                }
                if (solFile == null && itemFile == null)
                {
                    Console.WriteLine("Project file not found.");
                    return(1);
                }
            }
            else
            {
                if (Services.ProjectService.IsWorkspaceItemFile(file))
                {
                    solFile = file;
                }
                else if (Services.ProjectService.IsSolutionItemFile(file))
                {
                    itemFile = file;
                }
                else
                {
                    Console.WriteLine("File '{0}' is not a project or solution.", file);
                    return(1);
                }
            }

            IProgressMonitor monitor = new ConsoleProjectLoadProgressMonitor(new ConsoleProgressMonitor());

            TargetRuntime targetRuntime  = null;
            TargetRuntime defaultRuntime = Runtime.SystemAssemblyService.DefaultRuntime;

            if (runtime != null)
            {
                targetRuntime = MonoTargetRuntimeFactory.RegisterRuntime(new MonoRuntimeInfo(runtime));
                if (targetRuntime != null)
                {
                    Runtime.SystemAssemblyService.DefaultRuntime = targetRuntime;
                }
            }

            IBuildTarget item;

            if (solFile != null)
            {
                item = Services.ProjectService.ReadWorkspaceItem(monitor, solFile);
            }
            else
            {
                item = Services.ProjectService.ReadSolutionItem(monitor, itemFile);
            }

            using (var readItem = item) {
                if (project != null)
                {
                    Solution solution = item as Solution;
                    item = null;

                    if (solution != null)
                    {
                        item = solution.FindProjectByName(project);
                    }
                    if (item == null)
                    {
                        Console.WriteLine("The project '" + project + "' could not be found in " + file);
                        return(1);
                    }
                }

                IConfigurationTarget configTarget = item as IConfigurationTarget;
                if (config == null && configTarget != null)
                {
                    config = configTarget.DefaultConfigurationId;
                }

                monitor = new ConsoleProgressMonitor();
                BuildResult res = null;
                if (item is SolutionEntityItem && ((SolutionEntityItem)item).ParentSolution == null)
                {
                    ConfigurationSelector configuration = new ItemConfigurationSelector(config);
                    res = item.RunTarget(monitor, command, configuration);
                }
                else
                {
                    ConfigurationSelector configuration      = new SolutionConfigurationSelector(config);
                    SolutionEntityItem    solutionEntityItem = item as SolutionEntityItem;
                    if (solutionEntityItem != null)
                    {
                        if (command == ProjectService.BuildTarget)
                        {
                            res = solutionEntityItem.Build(monitor, configuration, true);
                        }
                        else if (command == ProjectService.CleanTarget)
                        {
                            solutionEntityItem.Clean(monitor, configuration);
                        }
                        else
                        {
                            res = item.RunTarget(monitor, command, configuration);
                        }
                    }
                    else
                    {
                        res = item.RunTarget(monitor, command, configuration);
                    }
                }


                if (targetRuntime != null)
                {
                    Runtime.SystemAssemblyService.DefaultRuntime = defaultRuntime;
                    MonoTargetRuntimeFactory.UnregisterRuntime((MonoTargetRuntime)targetRuntime);
                }

                if (res != null)
                {
                    foreach (var err in res.Errors)
                    {
                        Console.Error.WriteLine(err);
                    }
                }

                return((res == null || res.ErrorCount == 0) ? 0 : 1);
            }
        }
Ejemplo n.º 10
0
        public int Run(string[] arguments)
        {
            if (arguments.Length == 0 || arguments [0] == "--help")
            {
                Console.WriteLine("");
                Console.WriteLine("Project Export Tool");
                Console.WriteLine("Usage: mdtool project-export <source-project-file> [-d:dest-path] [-f:format-name]");
                Console.WriteLine("");
                Console.WriteLine("Options");
                Console.WriteLine("  -d:<dest-path>      Directory where the project will be exported.");
                Console.WriteLine("  -f:\"<format-name>\"  Format to which export the project or solution.");
                Console.WriteLine("  -l                  Show a list of all allowed target formats.");
                Console.WriteLine("");
                Console.WriteLine("  The format name is optional. A list of allowed file formats will be");
                Console.WriteLine("  shown if none is provided.");
                Console.WriteLine("");
                return(0);
            }

            string projectFile = null;
            string destPath    = null;
            string formatName  = null;
            bool   formatList  = false;

            foreach (string s in arguments)
            {
                if (s.StartsWith("-d:"))
                {
                    destPath = s.Substring(3);
                }
                else if (s.StartsWith("-f:"))
                {
                    formatName = s.Substring(3);
                }
                else if (s == "-l")
                {
                    formatList = true;
                }
                else if (projectFile != null)
                {
                    Console.WriteLine("Only one project can be converted at a time.");
                    return(1);
                }
                else
                {
                    projectFile = s;
                }
            }

            if (projectFile == null)
            {
                Console.WriteLine("Project or solution file name not provided.");
                return(1);
            }

            projectFile = FileService.GetFullPath(projectFile);
            if (!File.Exists(projectFile))
            {
                Console.WriteLine("File {0} not found.", projectFile);
                return(1);
            }

            ConsoleProgressMonitor monitor = new ConsoleProgressMonitor();

            monitor.IgnoreLogMessages = true;


            object item;

            if (Services.ProjectService.IsWorkspaceItemFile(projectFile))
            {
                item = Services.ProjectService.ReadWorkspaceItem(monitor, projectFile);
            }
            else
            {
                item = Services.ProjectService.ReadSolutionItem(monitor, projectFile);
            }

            FileFormat[] formats = Services.ProjectService.FileFormats.GetFileFormatsForObject(item);

            if (formats.Length == 0)
            {
                Console.WriteLine("Can't convert file to any format: " + projectFile);
                return(1);
            }

            FileFormat format = null;

            if (formatName == null || formatList)
            {
                Console.WriteLine();
                Console.WriteLine("Target formats:");
                for (int n = 0; n < formats.Length; n++)
                {
                    Console.WriteLine("  {0}. {1}", n + 1, formats [n].Name);
                }
                Console.WriteLine();
                if (formatList)
                {
                    return(0);
                }

                int op = 0;
                do
                {
                    Console.Write("Convert to format: ");
                    string s = Console.ReadLine();
                    if (s.Length == 0)
                    {
                        return(1);
                    }
                    if (int.TryParse(s, out op))
                    {
                        if (op > 0 && op <= formats.Length)
                        {
                            break;
                        }
                    }
                } while (true);

                format = formats [op - 1];
            }
            else
            {
                foreach (FileFormat f in formats)
                {
                    if (f.Name == formatName)
                    {
                        format = f;
                    }
                }
                if (format == null)
                {
                    Console.WriteLine("Unknown file format: " + formatName);
                    return(1);
                }
            }

            if (destPath == null)
            {
                destPath = Path.GetDirectoryName(projectFile);
            }
            destPath = FileService.GetFullPath(destPath);

            string ofile = Services.ProjectService.Export(monitor, projectFile, destPath, format);

            if (ofile != null)
            {
                Console.WriteLine("Saved file: " + ofile);
                return(0);
            }
            else
            {
                Console.WriteLine("Project export failed.");
                return(1);
            }
        }
        public int Run(string [] arguments)
        {
            Console.WriteLine("MonoDevelop Makefile generator");
            if (arguments.Length == 0)
            {
                ShowUsage();
                return(0);
            }

            // Parse arguments
            foreach (string s in arguments)
            {
                if (s == "--simple-makefiles" || s == "-s")
                {
                    generateAutotools = false;
                }
                else if (s.StartsWith("-d:"))
                {
                    if (s.Length > 3)
                    {
                        defaultConfig = s.Substring(3);
                    }
                }
                else if (s [0] == '-')
                {
                    Console.WriteLine(GettextCatalog.GetString("Error: Unknown option {0}", s));
                    return(1);
                }
                else
                {
                    if (filename != null)
                    {
                        Console.WriteLine(GettextCatalog.GetString("Error: Filename already specified - {0}, another filename '{1}' cannot be specified.", filename, s));
                        return(1);
                    }

                    filename = s;
                }
            }

            if (filename == null)
            {
                Console.WriteLine(GettextCatalog.GetString("Error: Solution file not specified."));
                ShowUsage();
                return(1);
            }

            Console.WriteLine(GettextCatalog.GetString("Loading solution file {0}", filename));
            ConsoleProgressMonitor monitor = new ConsoleProgressMonitor();

            Solution solution = Services.ProjectService.ReadWorkspaceItem(monitor, filename) as Solution;

            if (solution == null)
            {
                Console.WriteLine(GettextCatalog.GetString("Error: Makefile generation supported only for solutions.\n"));
                return(1);
            }

            if (defaultConfig == null || !CheckValidConfig(solution, defaultConfig))
            {
                Console.WriteLine(GettextCatalog.GetString("\nInvalid configuration {0}. Valid configurations : ", defaultConfig));
                for (int i = 0; i < solution.Configurations.Count; i++)
                {
                    SolutionConfiguration cc = (SolutionConfiguration)solution.Configurations [i];
                    Console.WriteLine("\t{0}. {1}", i + 1, cc.Id);
                }

                int configCount = solution.Configurations.Count;
                int op          = 0;
                do
                {
                    Console.Write(GettextCatalog.GetString("Select configuration : "));
                    string s = Console.ReadLine();
                    if (s.Length == 0)
                    {
                        return(1);
                    }
                    if (int.TryParse(s, out op))
                    {
                        if (op > 0 && op <= configCount)
                        {
                            break;
                        }
                    }
                } while (true);

                defaultConfig = solution.Configurations [op - 1].Id;
            }

            SolutionDeployer deployer = new SolutionDeployer(generateAutotools);

            if (deployer.HasGeneratedFiles(solution))
            {
                string msg = GettextCatalog.GetString("{0} already exist for this solution.  Would you like to overwrite them? (Y/N)",
                                                      generateAutotools ? "Autotools files" : "Makefiles");
                bool op = false;
                do
                {
                    Console.Write(msg);
                    string line = Console.ReadLine();
                    if (line.Length == 0)
                    {
                        return(1);
                    }

                    if (line.Length == 1)
                    {
                        if (line [0] == 'Y' || line [0] == 'y')
                        {
                            op = true;
                        }
                        else if (line [0] == 'N' || line [0] == 'n')
                        {
                            op = false;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        if (String.Compare(line, "YES", true) == 0)
                        {
                            op = true;
                        }
                        else if (String.Compare(line, "NO", true) == 0)
                        {
                            op = false;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    break;
                } while (true);
                if (!op)
                {
                    return(0);
                }
            }

            DeployContext ctx = new DeployContext(new TarballDeployTarget(), "Linux", null);

            try {
                deployer.GenerateFiles(ctx, solution, defaultConfig, monitor);
            }
            finally {
                ctx.Dispose();
                monitor.Dispose();
            }

            return(0);
        }