Beispiel #1
0
        static async Task ProcessProject(string project)
        {
            Console.WriteLine($"Process project {project}");
            var refs = ProjectParser.GetDependencies(project);

            using (var client = new HttpClient()) {
                var nuget = new NuGetClient(client);
                foreach (var item in refs)
                {
                    try {
                        var update = await ProcessPackage(nuget, item);

                        if (update)
                        {
                            Update(project, item.Include);
                        }
                    } catch (Exception e) {
                        Console.WriteLine($" ~ Failed {item.Include}");
                        // Console.WriteLine($" ~ {e.Message}");
                        // Console.WriteLine($" ~ {e.StackTrace}");
                    }
                }
            }
            Console.WriteLine();
        }
Beispiel #2
0
        static async Task <bool> ProcessPackage(NuGetClient nuget, Dependency dependency)
        {
            var packages = await nuget.GetPackageInfo(dependency.Include);

            var latest        = packages.Versions.First(x => !x.IsPrerelease);
            var latestVersion = latest.ToString();

            if (string.Compare(dependency.Version, latestVersion) < 0 && !String.IsNullOrEmpty(dependency.Version))
            {
                Console.WriteLine($" Update {dependency.Include} from {dependency.Version} to {latestVersion}");
                return(true);
            }
            else
            {
                var semver = SemanticVersion.Parse(dependency.Version);
                if (semver.IsPrerelease)
                {
                    Console.WriteLine($" Update {dependency.Include} from {dependency.Version} to {latestVersion}");
                    return(true);
                }
                else
                {
                    Console.WriteLine($" Skip {dependency.Include} {dependency.Version}");
                    return(false);
                }
            }
        }