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; } } }
public void test_framework_filter() { var net5query = new SearchQueryFilter() { TargetFramework = "net5.0" }; var net3query = new SearchQueryFilter() { TargetFramework = "netcoreapp3.1" }; var expectedNet5ProjectCount = 1; var expectedNet3ProjectCount = 2; var net5queryResults = _projectFileService.GetProjectFilesByFilter(GetSamplesDir(), net5query, "*-csproj.xml"); Assert.Equal(expectedNet5ProjectCount, net5queryResults.Count()); var net3queryResults = _projectFileService.GetProjectFilesByFilter(GetSamplesDir(), net3query, "*-csproj.xml"); Assert.Equal(expectedNet3ProjectCount, net3queryResults.Count()); }