예제 #1
0
        public ConcurrentDictionary <string, PackageResult> list_run(ChocolateyConfiguration config, bool logResults = true)
        {
            var packageResults = new ConcurrentDictionary <string, PackageResult>();

            var packages = NugetList.GetPackages(config, _nugetLogger).ToList();

            foreach (var package in packages.or_empty_list_if_null())
            {
                if (logResults)
                {
                    if (config.RegularOuptut)
                    {
                        this.Log().Info(config.Verbose ? ChocolateyLoggers.Important : ChocolateyLoggers.Normal, () => "{0} {1}".format_with(package.Id, package.Version.to_string()));
                        if (config.Verbose)
                        {
                            this.Log().Info(() => " {0}{1} Description: {2}{1} Tags: {3}{1} Number of Downloads: {4}{1}".format_with(package.Title.escape_curly_braces(), Environment.NewLine, package.Description.escape_curly_braces(), package.Tags.escape_curly_braces(), package.DownloadCount <= 0 ? "n/a" : package.DownloadCount.to_string()));
                        }
                        // Maintainer(s):{3}{1} | package.Owners.join(", ") - null at the moment
                    }
                    else
                    {
                        this.Log().Info(config.Verbose ? ChocolateyLoggers.Important : ChocolateyLoggers.Normal, () => "{0}|{1}".format_with(package.Id, package.Version.to_string()));
                    }
                }
                else
                {
                    this.Log().Debug(() => "{0} {1}".format_with(package.Id, package.Version.to_string()));
                }

                packageResults.GetOrAdd(package.Id, new PackageResult(package, null));
            }

            return(packageResults);
        }
예제 #2
0
        public async Task <Package> GetByVersionAndIdAsync(string id, string version, bool isPrerelease)
        {
            _choco.Set(
                config =>
            {
                config.CommandName       = "list";
                config.Input             = id;
                config.ListCommand.Exact = true;
                config.Version           = version;
                config.QuietOutput       = true;
                config.RegularOutput     = false;
#if !DEBUG
                config.Verbose = false;
#endif // DEBUG
            });
            var chocoConfig = _choco.GetConfiguration();

            var nugetLogger  = _choco.Container().GetInstance <NuGet.ILogger>();
            var semvar       = new SemanticVersion(version);
            var nugetPackage = await Task.Run(() => (NugetList.GetPackages(chocoConfig, nugetLogger) as IQueryable <IPackage>).FirstOrDefault(p => p.Version == semvar));

            if (nugetPackage == null)
            {
                throw new Exception("No Package Found");
            }

            return(GetMappedPackage(_choco, new PackageResult(nugetPackage, null, chocoConfig.Sources), _mapper));
        }