/// <summary> /// Updates the specified NuGet packages. Returns `true` if the package was successfully updated. /// </summary> private static bool UpdatePackages( List <string> newPackageFiles, BuildVersion roslynBuildVersion, CoreXT coreXT, string packagesDir, CancellationToken cancellationToken) { bool shouldRetainBuild = false; // All CoreXT packages we insert: var packagePaths = Directory.EnumerateFiles(packagesDir, "*.nupkg", SearchOption.AllDirectories); foreach (var packagePath in packagePaths) { cancellationToken.ThrowIfCancellationRequested(); var fileName = Path.GetFileName(packagePath); Log.Info($"Processing package '{packagePath}'"); var package = PackageInfo.ParsePackageFileName(fileName); if (package.IsRoslynToolsetCompiler) { // The toolset compiler is inserted separately continue; } if (!coreXT.TryGetPackageVersion(package, out var previousPackageVersion)) { Log.Info($"New package is being inserted: '{package}'"); coreXT.AddNewPackage(package); newPackageFiles.Add(fileName); shouldRetainBuild = true; continue; } UpdatePackage(previousPackageVersion, roslynBuildVersion, coreXT, package); } return(shouldRetainBuild); }
/// <summary> /// Updates the specified NuGet packages. Returns `true` if the package was successfully updated. /// </summary> private static (bool success, List <string> newPackageFiles) UpdatePackages( BuildVersion buildVersion, CoreXT coreXT, string packagesDir, ImmutableArray <string> packagesToBeIgnored, CancellationToken cancellationToken) { bool shouldRetainBuild = false; var newPackageFiles = new List <string>(); // All CoreXT packages we insert: var packagePaths = Directory.EnumerateFiles(packagesDir, "*.nupkg", SearchOption.AllDirectories); foreach (var packagePath in packagePaths) { cancellationToken.ThrowIfCancellationRequested(); var fileName = Path.GetFileName(packagePath); Console.WriteLine($"Processing package '{packagePath}'"); var package = PackageInfo.ParsePackageFileName(fileName); if (package.IsRoslynToolsetCompiler || packagesToBeIgnored.Any(p => p == package.PackageName)) { continue; } if (!coreXT.TryGetPackageVersion(package, out var previousPackageVersion)) { Console.WriteLine($"New package is being inserted: '{package}'"); coreXT.AddNewPackage(package); newPackageFiles.Add(fileName); shouldRetainBuild = true; continue; } UpdatePackage(previousPackageVersion, buildVersion, coreXT, package); } return(shouldRetainBuild, newPackageFiles); }