static void Execute(string basePath, SearchQueryFilter filter, string?setVersion, string outputFile, string outputFileFormatStr) { var tools = new ProjectNugetVersionUpdater(new DotNetPackageReferenceUpdater()); var projFileService = new ProjectFileService(); OutputFileFormat outputFormat = !string.IsNullOrEmpty(outputFileFormatStr) ? Enum.Parse <OutputFileFormat>(outputFileFormatStr, true) : OutputFileFormat.Default; IProjectFileResultsRenderer projectFileRenderer; basePath = Path.GetFullPath(basePath); var projFiles = projFileService.GetProjectFilesByFilter(basePath, filter); if (!string.IsNullOrEmpty(outputFile)) { var outputFilePath = Path.GetFullPath(outputFile); Console.Write($"Writing output to {outputFilePath}"); if (!string.IsNullOrEmpty(outputFileFormatStr)) { Console.Write($" format: {outputFileFormatStr}"); } Console.WriteLine(); // no format so just redirect FileOutput.RedirectConsoleToFile(outputFilePath); } switch (outputFormat) { case OutputFileFormat.Json: projectFileRenderer = new ProjectFileJsonRenderer(); break; default: projectFileRenderer = new ProjectFileConsoleRenderer(); break; } projectFileRenderer.RenderResults(basePath, filter, projFiles); if (!string.IsNullOrEmpty(setVersion)) { var startTabPad = 10; var strPad = new string(' ', startTabPad); if (projFileService.SetNugetPackageVersions(filter, setVersion, projFiles, strPad, tools)) { return; } } }
static void Main(string[] args) { Console.WriteLine($"NugetVersion - v{GetVersion().ToString()}"); var app = PrepCommandLineApplication(); // Some fudge to get command line parameters sorted var argList = args.ToList(); if (argList.Any()) { if (!argList.First().Trim().StartsWith("-") && !argList.Any(x => x.Trim().Contains("-b") || x.Trim().Contains("--base"))) { var basePath = argList.First(); argList[0] = "-b " + basePath; } else if (argList.Any(x => x.Contains("-")) && argList.First().Trim().StartsWith("-")) { argList.Insert(0, "-b ."); } app.Execute(argList.ToArray()); FileOutput.EndRedirection(); } else { app.ShowHelp(); } //Console.WriteLine("Completed."); if (Debugger.IsAttached) { Console.ReadKey(); } }