static IEnumerable <PublishedPackage> GetAllPublishedPackages()
        {
            var packagingSource = new PackagingSource {
                FeedUrl = BlogSettings.Instance.GalleryFeedUrl
            };
            var allPacks = new List <PublishedPackage>();

            // gallery has a limit 100 records per call
            // keep calling till any records returned
            int cnt;
            var skip = 0;

            do
            {
                var s = skip;
                var galleryFeedContext = new GalleryFeedContext(new Uri(BlogSettings.Instance.GalleryFeedUrl))
                {
                    IgnoreMissingProperties = true
                };

                // dnbegallery.org overrides feed with additional values in "screenshots" section
                var pkgs = (new[] { packagingSource }).SelectMany(source => {
                    return(galleryFeedContext.Packages.Expand("Screenshots").OrderBy(p => p.Id).Where(p => p.IsLatestVersion).Skip(s).Take(100));
                });

                cnt  = pkgs.Count();
                skip = skip + 100;
                allPacks.AddRange(pkgs);
            } while (cnt > 0);

            return(allPacks);
        }
Ejemplo n.º 2
0
        private static IEnumerable <PackagingEntry> GetExtensionListFromSource(bool includeScreenshots, PackagingSource packagingSource, Func <IQueryable <PublishedPackage>, IQueryable <PublishedPackage> > query, PackagingSource source)
        {
            var galleryFeedContext = new GalleryFeedContext(new Uri(source.FeedUrl))
            {
                IgnoreMissingProperties = true
            };

            // Setup compression
            galleryFeedContext.SendingRequest += (o, e) => {
                if (e.Request is HttpWebRequest)
                {
                    (e.Request as HttpWebRequest).AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
                }
            };

            // Include screenshots if needed
            IQueryable <PublishedPackage> packages = includeScreenshots
                ? galleryFeedContext.Packages.Expand("Screenshots")
                : galleryFeedContext.Packages;

            if (query != null)
            {
                packages = query(packages);
            }

            return(packages.ToList().Select(p => CreatePackageEntry(p, packagingSource, galleryFeedContext.GetReadStreamUri(p))));
        }
Ejemplo n.º 3
0
 static IEnumerable <PublishedPackage> GetPublishedPackages(PackagingSource packagingSource = null)
 {
     return((new[] { packagingSource })
            .SelectMany(
                source =>
     {
         var galleryFeedContext = new GalleryFeedContext(new Uri(_feedUrl))
         {
             IgnoreMissingProperties = true
         };
         return galleryFeedContext.Packages.Expand("Screenshots");
     }
                ));
 }
        /// <summary>
        /// Retrieves the number of extensions from a feed source.
        /// </summary>
        /// <param name="packagingSource">The packaging source from where to get the extensions.</param>
        /// <param name="query">The optional query to retrieve the extensions.</param>
        /// <returns>The number of extensions from a feed source.</returns>
        public int GetExtensionCount(PackagingSource packagingSource = null, Func <IQueryable <PublishedPackage>, IQueryable <PublishedPackage> > query = null)
        {
            return((packagingSource == null ? GetSources() : new[] { packagingSource })
                   .Sum(source => {
                var galleryFeedContext = new GalleryFeedContext(new Uri(source.FeedUrl));
                IQueryable <PublishedPackage> packages = galleryFeedContext.Packages;

                if (query != null)
                {
                    packages = query(packages);
                }

                return packages.Count();
            }
                        ));
        }
        /// <summary>
        /// Retrieves the list of extensions from a feed source.
        /// </summary>
        /// <param name="includeScreenshots">Specifies if screenshots should be included in the result.</param>
        /// <param name="packagingSource">The packaging source from where to get the extensions.</param>
        /// <param name="query">The optional query to retrieve the extensions.</param>
        /// <returns>The list of extensions.</returns>
        public IEnumerable <PackagingEntry> GetExtensionList(bool includeScreenshots, PackagingSource packagingSource = null, Func <IQueryable <PublishedPackage>, IQueryable <PublishedPackage> > query = null)
        {
            return((packagingSource == null ? GetSources() : new[] { packagingSource })
                   .SelectMany(
                       source => {
                var galleryFeedContext = new GalleryFeedContext(new Uri(source.FeedUrl));
                IQueryable <PublishedPackage> packages = includeScreenshots
                            ? galleryFeedContext.Packages.Expand("Screenshots")
                            : galleryFeedContext.Packages;

                if (query != null)
                {
                    packages = query(packages);
                }

                return packages.ToList().Select(p => CreatePackageEntry(p, packagingSource, galleryFeedContext.GetReadStreamUri(p)));
            }
                       ));
        }
Ejemplo n.º 6
0
        public static void Main(string[] args)
        {
            Console.WriteLine("NuGet bootstrapper {0}", typeof(Program).Assembly.GetName().Version);

            // Get the package from the feed
            var context         = new GalleryFeedContext(new Uri(GalleryUrl));
            var packageMetadata = context.Packages.Where(p => p.Id.ToLower() == NuGetCommandLinePackageId)
                                  .AsEnumerable()
                                  .OrderByDescending(p => Version.Parse(p.Version))
                                  .FirstOrDefault();

            if (packageMetadata != null)
            {
                Console.WriteLine("Found NuGet.exe version {0}.", packageMetadata.Version);
                Console.WriteLine("Downloading...");

                Uri uri = context.GetReadStreamUri(packageMetadata);
                // TODO: Handle proxys
                WebClient client        = new WebClient();
                var       packageStream = new MemoryStream(client.DownloadData(uri));

                using (Package package = Package.Open(packageStream)) {
                    var         fileUri      = PackUriHelper.CreatePartUri(new Uri(NuGetExeFilePath, UriKind.Relative));
                    PackagePart nugetExePart = package.GetPart(fileUri);

                    if (nugetExePart != null)
                    {
                        // Get the exe path and move it to a temp file (NuGet.exe.old) so we can replace the running exe with the bits we got
                        // from the package repository
                        string exePath     = typeof(Program).Assembly.Location;
                        string renamedPath = exePath + ".old";
                        Move(exePath, renamedPath);

                        // Update the file
                        UpdateFile(exePath, nugetExePart);
                        Console.WriteLine("Update complete.");
                    }
                }
            }
        }