Ejemplo n.º 1
0
        private static void PrintNugetUsageFor(List <Solution> solutions, CommandLineOption opts)
        {
            DataTable table = new DataTable();

            table.Columns.Add("Solution", typeof(string));
            table.Columns.Add("Nuget Name", typeof(string));
            table.Columns.Add("Version", typeof(string));
            table.Columns.Add("Target Framework", typeof(string));

            if (!string.IsNullOrEmpty(opts.NugetOutputFile))
            {
                File.Delete(opts.NugetOutputFile);
            }
            solutions.ForEach(solution =>
            {
                solution.Nugets.ForEach(nuget =>
                {
                    if (!string.IsNullOrEmpty(opts.NugetOutputFile))
                    {
                        File.AppendAllText(opts.NugetOutputFile, $"{solution.Name};{nuget.Name};{nuget.Version};{nuget.TargetFramework};{Environment.NewLine}");
                    }
                    table.Rows.Add(solution.Name, nuget.Name, nuget.Version, nuget.TargetFramework);
                });
            });

            if (opts.Verbose)
            {
                ConsoleTableBuilder.From(table).ExportAndWriteLine();
            }
        }
Ejemplo n.º 2
0
        private static void PrintFwkVersion(List <Solution> solutions, CommandLineOption opts)
        {
            List <IGrouping <string, Solution> > a = solutions.GroupBy(s => s.TargetFramework).ToList();
            DataTable table = new DataTable();

            table.Columns.Add("Framework", typeof(string));
            table.Columns.Add("Projects", typeof(string));

            if (!string.IsNullOrEmpty(opts.NetFwkOutputFile))
            {
                File.Delete(opts.NetFwkOutputFile);
            }

            a.ForEach((grouping) =>
            {
                grouping.ToList().ForEach(solution =>
                {
                    if (!string.IsNullOrEmpty(opts.NetFwkOutputFile))
                    {
                        File.AppendAllText(opts.NetFwkOutputFile, $"{solution.Name};{solution.TargetFramework};{Environment.NewLine}");
                    }
                    table.Rows.Add(solution.TargetFramework, solution.Name);
                });
            });

            if (opts.Verbose)
            {
                ConsoleTableBuilder.From(table).ExportAndWriteLine();
            }
        }
Ejemplo n.º 3
0
        private static string GetSolutionsDirectory(CommandLineOption opts)
        {
            if (!string.IsNullOrEmpty(opts.ProjectDirectory))
            {
                if (!Directory.Exists(opts.ProjectDirectory))
                {
                    if (opts.Verbose)
                    {
                        Console.WriteLine($"Directory {opts.ProjectDirectory} does not exists");
                    }
                    throw new Exception();
                }

                return(opts.ProjectDirectory);
            }

            var dir = string.Empty;

            while (string.IsNullOrEmpty(dir))
            {
                Console.WriteLine("Please type the app root directory");
                dir = Console.ReadLine();

                if (!Directory.Exists(dir))
                {
                    Console.WriteLine($"{dir} does not exists");
                    dir = string.Empty;
                }
            }

            return(dir);
        }
Ejemplo n.º 4
0
        private static void PrintNugetConsolidationInformations(List <Solution> solutions, CommandLineOption opts)
        {
            IEnumerable <Nuget> nugets = solutions.SelectMany(s => s.Nugets);

            if (!string.IsNullOrEmpty(opts.FilterDependency))
            {
                nugets = nugets.Where(n => n.Name.Equals(opts.FilterDependency));
            }

            nugets.Select(n => n.Name).Distinct().ToList().ForEach(n =>
            {
                DataTable table = new DataTable();

                table.Columns.Add("Nuget Name", typeof(string));
                table.Columns.Add("Target Framework", typeof(string));
                table.Columns.Add("Used versions", typeof(string));

                nugets.Select(_n => _n.TargetFramework).Distinct().ToList().ForEach(tv =>
                {
                    var usedNugetVersions = nugets.Where(_n => _n.Name == n && _n.TargetFramework == tv).Select(_n => _n.Version).Distinct().ToList();
                    if (usedNugetVersions.Any())
                    {
                        table.Rows.Add(n, tv, string.Join(", ", usedNugetVersions));
                    }
                });

                if (opts.Verbose)
                {
                    ConsoleTableBuilder.From(table).ExportAndWriteLine();
                    Console.WriteLine(Environment.NewLine);
                }
            });
        }