Exemplo n.º 1
0
        private static PackageInfo GetPackageInfo(CatalogEntry entry)
        {
            try
            {
                // This is ugly. There must be something better. Not using Task.Run as we don't have any
                // synchronization context anyway.
                var nuspec = entry.GetNuspecAsync().Result;
                int loaded = Interlocked.Increment(ref s_loadedPackageCount);
                if (loaded % 100 == 0)
                {
                    Console.WriteLine($"{DateTime.UtcNow:HH:mm:ss} Loaded dependencies for {loaded} packages.");
                }

                return(new PackageInfo
                {
                    Id = entry.Id,
                    Version = entry.Version.ToString(),
                    Dependencies = nuspec.GetDependencyGroups()
                                   .SelectMany(dg => dg.Packages)
                                   .Select(d => d.Id)
                                   .Distinct()
                                   .ToList()
                });
            }
            catch
            {
                Console.WriteLine($"Failed to fetch dependencies for {entry.Id}");
                Interlocked.Increment(ref s_failureCount);
                return(null);
            }
        }