Пример #1
0
        static void Main(string[] args)
        {
            NuGetQuerier querier = new NuGetQuerier();

            NuGetDownloader downloader =
                new NuGetDownloader(querier.FetchFrom(TimeSpan.FromDays(1)),
                                    "nupkgs",
                                    30,
                                    0);

            IObservable<DownloadStatus<V2FeedPackage>> listener =
                downloader.Download();

            bool done = false;

            listener.Subscribe(x => HandleMessage((dynamic)x),
                               () =>
                                   {
                                       done = true;
                                       System.Console.WriteLine("Done!");
                                   });

            while (!done)
            {
                System.Console.ReadLine();
            }
        }
Пример #2
0
    static CompareSet GetExplicitAssembliesToCompare(string[] args)
    {
        var sourceIndex = Array.FindIndex(args, arg => arg == "--source");

        if (sourceIndex < 0)
        {
            throw new ApiComparerArgumentException("No target assemblies specified, please use --source {asm1};{asm2}...");
        }

        var targetIndex = Array.FindIndex(args, arg => arg == "--target");

        if (targetIndex < 0)
        {
            throw new ApiComparerArgumentException("No target assemblies specified, please use --target {asm1};{asm2}...");
        }

        var source = args[sourceIndex + 1];

        AssemblyGroup leftAsmGroup;

        string leftVersion;

        var compareName = "Custom";

        if (source.StartsWith("nuget:"))
        {
            var nugetName = source.Replace("nuget:", "").Trim();


            compareName = nugetName;

            var feeds = GetFeedsToUse(args);

            var nugetBrowser = new NuGetBrowser(feeds);

            var version = nugetBrowser.GetAllVersions(nugetName, args.Contains("--include-prerelease")).Max();

            var nugetDownloader = new NuGetDownloader(nugetName, feeds);

            leftVersion = version.ToString();

            leftAsmGroup = new AssemblyGroup(nugetDownloader.DownloadAndExtractVersion(leftVersion));
        }
        else
        {
            leftVersion = "TBD-Left";

            leftAsmGroup = new AssemblyGroup(source.Split(';').Select(Path.GetFullPath).ToList());
        }

        return(new CompareSet
        {
            Name = compareName,
            RightAssemblyGroup = new AssemblyGroup(args[targetIndex + 1].Split(';').Select(Path.GetFullPath).ToList()),
            LeftAssemblyGroup = leftAsmGroup,
            Versions = new VersionPair(leftVersion, "TBD-Right")
        });
    }
Пример #3
0
        public void Test_FillVPackage()
        {
            NuGetDownloader n     = new NuGetDownloader();
            string          lastV = n.GetLatestVersionPackage("Newtonsoft.Json");
            var             p     = n.FillVPackage("Newtonsoft.Json", lastV);

            Assert.AreEqual(p.PackageId, "Newtonsoft.Json");
            Assert.IsFalse(p.Dependencies.IsEmpty());
        }
Пример #4
0
        public PackageService()
        {
            AManager manager = new AManager();

            _packageReq  = new PackageRequests(manager);
            _vPackageReq = new VPackageRequests(manager);
            _nugetDL     = new NuGetDownloader();
            _graphData   = new GraphData();
        }
Пример #5
0
        public void Test_JsonSerializer()
        {
            JsonSerializerPackage s = new JsonSerializerPackage();
            NuGetDownloader       n = new NuGetDownloader();
            VPackage vp             = n.FillVPackage("Newtonsoft.Json", n.GetLatestVersionPackage("Newtonsoft.Json"));
            string   result         = s.JsonSerializer(vp);

            JObject rss = JObject.Parse(result);

            Console.WriteLine(rss);
            Assert.Pass();
        }
        public async Task Initialize()
        {
            var nuGetDownloader = new NuGetDownloader(_options.LoggerFactory());

            var packages = await nuGetDownloader.SearchPackagesAsync(_packageFeed, _searchTerm, maxResults : _maxPackages);

            foreach (var packageAndRepo in packages)
            {
                var packageCatalog = new NugetPackagePluginCatalog(packageAndRepo.Package.Identity.Id, packageAndRepo.Package.Identity.Version.ToString(),
                                                                   _includePrereleases, _packageFeed, PackagesFolder, criterias: _typeFinderCriterias);

                await packageCatalog.Initialize();

                _pluginCatalogs.Add(packageCatalog);
            }

            IsInitialized = true;
        }
Пример #7
0
    static CompareSet CreateCompareSet(List <string> feeds, string package, VersionPair versions)
    {
        var nugetDownloader = new NuGetDownloader(package, feeds);

        Console.Out.Write("Preparing {0}-{1}", package, versions);

        var leftAssemblyGroup  = new AssemblyGroup(nugetDownloader.DownloadAndExtractVersion(versions.LeftVersion));
        var rightAssemblyGroup = new AssemblyGroup(nugetDownloader.DownloadAndExtractVersion(versions.RightVersion));

        Console.Out.WriteLine(" done");

        return(new CompareSet
        {
            Name = package,
            RightAssemblyGroup = rightAssemblyGroup,
            LeftAssemblyGroup = leftAssemblyGroup,
            Versions = versions
        });
    }
Пример #8
0
    static CompareSet CreateCompareSet(string package, VersionPair versions)
    {
        var nugetDownloader = new NuGetDownloader(package, new List<string> { "https://www.nuget.org/api/v2" });

        Console.Out.Write("Preparing {0}-{1}", package, versions);

        var leftAssemblyGroup = new AssemblyGroup(nugetDownloader.DownloadAndExtractVersion(versions.LeftVersion));
        var rightAssemblyGroup = new AssemblyGroup(nugetDownloader.DownloadAndExtractVersion(versions.RightVersion));

        Console.Out.WriteLine(" done");

        return new CompareSet
        {
            Name = package,
            RightAssemblyGroup = rightAssemblyGroup,
            LeftAssemblyGroup = leftAssemblyGroup,
            Versions = versions
        };
    }
Пример #9
0
        public static async Task Main(string[] args)
        {
            try
            {
                var isHelp     = false;
                var parameters = new DownloaderParameters
                {
                    PackageOutputPath = GetTemporaryOutputPath(),
                };

                var options = new OptionSet
                {
                    { "help|h", "Displays this help screen", s => isHelp = true },
                    { "solution|s=", "Path to the {solution}", s => parameters.SolutionPath = s },
                    { "output|o=", "Path where to extract the packages; optional, defaults to a temporary folder", s => parameters.PackageOutputPath = s },
                    { "sourceFeed=|sf=", "The NuGet feed from where to download the packages; a private feed can be specified with the format {url|accessToken}", s => parameters.Source = PackageFeed.FromString(s) },
                    { "targetFeed=|tf=", "The NuGet feed where to push the packages; a private feed can be specified with the format {url|accessToken}; optional", s => parameters.Target = PackageFeed.FromString(s) },
                };

                options.Parse(args);

                if (isHelp)
                {
                    Console.WriteLine("NuGet Downloader is a tool allowing the download of the NuGet packages found in a solution");
                    Console.WriteLine();
                    options.WriteOptionDescriptions(Console.Out);
                }

                var result = await NuGetDownloader.RunAsync(CancellationToken.None, parameters, ConsoleLogger.Instance);

                Console.WriteLine($"{result.DownloadedPackages.Length} packages have been downloaded under {parameters.PackageOutputPath}");

                if (parameters.Target != null)
                {
                    Console.WriteLine($"{result.PushedPackages?.Length ?? 0} packages have been pushed to {parameters.Target.Url}");
                }
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine($"Failed to download nuget packages: {ex.Message}");
                Console.Error.WriteLine($"{ex}");
            }
        }
        public async Task Initialize()
        {
            var nuGetDownloader = new NuGetDownloader(_options.LoggerFactory());

            var nugetDownloadResult = await nuGetDownloader.DownloadAsync(PackagesFolder, _packageName, _packageVersion, _includePrerelease, _packageFeed,
                                                                          includeSecondaryRepositories : _options.IncludeSystemFeedsAsSecondary, targetFramework : _options.TargetFramework).ConfigureAwait(false);

            foreach (var f in nugetDownloadResult.PackageAssemblyFiles)
            {
                _pluginAssemblyFilePaths.Add(Path.Combine(PackagesFolder, f));
            }

            foreach (var pluginAssemblyFilePath in _pluginAssemblyFilePaths)
            {
                var options = new AssemblyPluginCatalogOptions
                {
                    TypeFinderOptions = _options.TypeFinderOptions, PluginNameOptions = _options.PluginNameOptions
                };

                var downloadedRuntimeDlls = nugetDownloadResult.RunTimeDlls.Where(x => x.IsRecommended).ToList();

                var runtimeAssemblyHints = new List <RuntimeAssemblyHint>();

                foreach (var runTimeDll in downloadedRuntimeDlls)
                {
                    var runtimeAssembly = new RuntimeAssemblyHint(runTimeDll.FileName, runTimeDll.FullFilePath, runTimeDll.IsNative);
                    runtimeAssemblyHints.Add(runtimeAssembly);
                }

                options.PluginLoadContextOptions.RuntimeAssemblyHints = runtimeAssemblyHints;

                var assemblyCatalog = new AssemblyPluginCatalog(pluginAssemblyFilePath, options);
                await assemblyCatalog.Initialize();

                _pluginCatalogs.Add(assemblyCatalog);
            }

            IsInitialized = true;
        }
Пример #11
0
        private void InitializeNuget()
        {
            _nuGetDownloader = new NuGetDownloader();
            _nugetConfigPath = Configuration.NugetConfigPath;

            if (string.IsNullOrWhiteSpace(_nugetConfigPath))
            {
                _logger.Info(
                    "No nuget.config path is set, use machines default nuget configuration. To use custom Nuget.Config, please set configuration 'nuget'");
            }
            else
            {
                _logger.Info("Nuget.config path is set to {NugetConfigPath}, using that for the Nuget sources. No machine wide Nuget configurations are used",
                             _nugetConfigPath);

                if (!File.Exists(_nugetConfigPath))
                {
                    _logger.Error("Nuget.config path was set to {NugetConfigPath}, but the file is missing", _nugetConfigPath);

                    throw new Exception($"Nuget configuration file {_nugetConfigPath} is missing");
                }
            }
        }
        public async Task Initialize()
        {
            var nuGetDownloader         = new NuGetDownloader(_options.LoggerFactory());
            var pluginAssemblyFileNames = await nuGetDownloader.DownloadAsync(PackagesFolder, _packageName, _packageVersion, _includePrerelease, _packageFeed);

            foreach (var f in pluginAssemblyFileNames)
            {
                _pluginAssemblyFilePaths.Add(Path.Combine(PackagesFolder, f));
            }

            foreach (var pluginAssemblyFilePath in _pluginAssemblyFilePaths)
            {
                var options = new AssemblyPluginCatalogOptions {
                    TypeFinderOptions = _options.TypeFinderOptions, PluginNameOptions = _options.PluginNameOptions
                };

                var assemblyCatalog = new AssemblyPluginCatalog(pluginAssemblyFilePath, options);
                await assemblyCatalog.Initialize();

                _pluginCatalogs.Add(assemblyCatalog);
            }

            IsInitialized = true;
        }
Пример #13
0
 public void Test_Package()
 {
     NuGetDownloader n = new NuGetDownloader();
 }
Пример #14
0
    private static CompareSet GetExplicitAssembliesToCompare(string[] args)
    {
        var sourceIndex = Array.FindIndex(args, arg => arg == "--source");

        if (sourceIndex < 0)
        {
            throw new Exception("No target assemblies specified, please use --source {asm1};{asm2}...");
        }

        var targetIndex = Array.FindIndex(args, arg => arg == "--target");

        if (targetIndex < 0)
        {
            throw new Exception("No target assemblies specified, please use --target {asm1};{asm2}...");
        }

        var source = args[sourceIndex + 1];

        AssemblyGroup leftAsmGroup;

        string leftVersion;

        var compareName = "Custom";

        if (source.StartsWith("nuget:"))
        {

            var nugetName = source.Replace("nuget:", "").Trim();

            compareName = nugetName;

            var feeds = GetFeedsToUse(args);

            var nugetBrowser = new NuGetBrowser(feeds);

            var version = nugetBrowser.GetAllVersions(nugetName,args.Contains("--include-prerelease")).Max();

            var nugetDownloader = new NuGetDownloader(nugetName, feeds);

            leftVersion = version.ToString();

            leftAsmGroup = new AssemblyGroup(nugetDownloader.DownloadAndExtractVersion(leftVersion));
        }
        else
        {
            leftVersion = "TBD-Left";

            leftAsmGroup = new AssemblyGroup(source.Split(';').Select(Path.GetFullPath).ToList());
        }

        return new CompareSet
        {
            Name = compareName,
            RightAssemblyGroup = new AssemblyGroup(args[targetIndex + 1].Split(';').Select(Path.GetFullPath).ToList()),
            LeftAssemblyGroup = leftAsmGroup,
            Versions = new VersionPair(leftVersion, "TBD-Right")

        };
    }