private static Solution GenerateAllProjects(string binariesPath, bool generateEntryProject, IEnumerable <string> paths) { var fullPaths = paths.Select(Path.GetFullPath).ToArray(); Scanner.Instance.ScanDirectories(fullPaths); var mainProject = Scanner.Instance.Projects.OfType <UiProject>().FirstOrDefault(); if (mainProject == null) { Console.Error.WriteLine("No UI project found. Exiting"); Environment.Exit(ErrorResultCode); } return(SolutionGenerator.GenerateWithAllReferences(mainProject, generateEntryProject, binariesPath, Scanner.Instance.Projects.Where(x => !(x is UnknownProject)))); }
private static Configuration GenerateAllProjects(Options options) { Scanner.Instance.ScanDirectories(options.Directories.Select(Path.GetFullPath), options.Exclude); var mainProject = (options.MainProject != null) ? Scanner.Instance.Elements.OfType <UiProject>().Where(x => x.Path == options.MainProject).SingleOrDefault() : Scanner.Instance.Elements.OfType <UiProject>().OrderByDescending(x => x.Name == "CLI").FirstOrDefault(); if (mainProject == null) { Console.Error.WriteLine("No UI project found. Exiting"); Environment.Exit(ErrorResultCode); } return(new Configuration( SolutionGenerator.GenerateWithAllReferences(options.SolutionName, mainProject, options.GenerateEntryProject, options.BinariesDirectory, Scanner.Instance.Elements.OfType <Project>().Where(x => !(x is UnknownProject))), Scanner.Instance.Elements.OfType <RobotTestSuite>())); }
private static int HandleInteractive(List <string> directories, string binariesDirectory, string outputDirectory, bool generateEntryProject) { // check if "dialog" application is available if (!TryFind("dialog")) { Console.Error.WriteLine("The 'dialog' application is necessary to run in interactive mode"); return(ErrorResultCode); } if (directories == null || directories.All(x => string.IsNullOrEmpty(x))) { var directoryDialog = new InputboxDialog(Title, "Provide directories to scan (colon-separated):", "."); if (directoryDialog.Show() != DialogResult.Ok) { return(CancelResultCode); } directories = directoryDialog.Value.Split(new [] { ':' }, StringSplitOptions.RemoveEmptyEntries).ToList(); } if (!directories.Any()) { new MessageDialog("Error", "No directories to scan provided! Exiting.").Show(); return(ErrorResultCode); } Solution solution = null; var infobox = new Infobox("Scanning directories..."); infobox.Show(); Scanner.Instance.ScanDirectories(directories); var actions = new List <Tuple <string, string> > { Tuple.Create("All", "Generate solution file with all projects"), Tuple.Create("Custom", "Generate custom solution file"), Tuple.Create("Clean", "Remove generated configuration") }; foreach (var uiType in Scanner.Instance.Projects.OfType <UiProject>().Select(x => x.UiType).Distinct().OrderByDescending(x => x)) { actions.Insert(1, Tuple.Create(uiType, string.Format("Generate solution file for {0} with references", uiType))); } var actionDialog = new MenuDialog(Title, "Welcome to the Emul8 bootstrap configuration.\nUse this script to generate your own Emul8.sln file.\n\nChoose action:", actions); if (actionDialog.Show() != DialogResult.Ok) { return(CancelResultCode); } try { var key = actionDialog.SelectedKeys.First(); switch (key) { case "All": solution = GenerateAllProjects(binariesDirectory, generateEntryProject, directories); break; case "Custom": solution = HandleCustomSolution(binariesDirectory, generateEntryProject, directories); break; case "Clean": Cleaner.Clean(outputDirectory); new MessageDialog(Title, "Solution cleaned.").Show(); return(CleanedResultCode); default: var mainProject = Scanner.Instance.Projects.OfType <UiProject>().SingleOrDefault(x => x.UiType == key); if (mainProject == null) { new MessageDialog("Bootstrap failure", string.Format("Could not load {0} project. Exiting", key)).Show(); return(ErrorResultCode); } solution = SolutionGenerator.GenerateWithAllReferences(mainProject, generateEntryProject, binariesDirectory); break; } } catch (DirectoryNotFoundException e) { new MessageDialog("Error", e.Message).Show(); return(ErrorResultCode); } if (solution == null) { new MessageDialog("Bootstrap failure", "Couldn't generate the solution file: no project file found in the directories provided. Exiting").Show(); return(ErrorResultCode); } var confirmDialog = new YesNoDialog(Title, "Are you sure you want to create the solution file?"); if (confirmDialog.Show() != DialogResult.Ok) { return(CancelResultCode); } solution.Save(outputDirectory); solution.SaveTestsFile(Path.Combine(outputDirectory, testsFileName)); new MessageDialog(Title, "Solution file created successfully!").Show(); return(0); }