Exemplo n.º 1
0
        protected override string GetLatestVersionCore(bool ignorePrerelease)
        {
            IEnumerable <string> allVersions = null;

            if (FileSystemProxy.DirectoryExists(NugetSource))
            {
                var paketPrefix = "paket.";
                allVersions = FileSystemProxy.
                              EnumerateFiles(NugetSource, "paket.*.nupkg", SearchOption.TopDirectoryOnly).
                              Select(x => Path.GetFileNameWithoutExtension(x)).
                              // If the specified character isn't a digit, then the file
                              // likely contains the bootstrapper or paket.core
                              Where(x => x.Length > paketPrefix.Length && Char.IsDigit(x[paketPrefix.Length])).
                              Select(x => x.Substring(paketPrefix.Length));
            }
            else
            {
                var apiHelper         = new NugetApiHelper(PaketNugetPackageName, NugetSource);
                var versionRequestUrl = apiHelper.GetAllPackageVersions(!ignorePrerelease);
                var versions          = WebRequestProxy.DownloadString(versionRequestUrl);
                allVersions = versions.
                              Trim('[', ']').
                              Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).
                              Select(x => x.Trim('"'));
            }
            var latestVersion = allVersions.
                                Select(SemVer.Create).
                                Where(x => !ignorePrerelease || (x.PreRelease == null)).
                                OrderBy(x => x).
                                LastOrDefault(x => !String.IsNullOrWhiteSpace(x.Original));

            return(latestVersion != null ? latestVersion.Original : String.Empty);
        }
Exemplo n.º 2
0
        internal async Task <Dictionary <string, TValue> > GetLatestArchiveAsync <TValue>(string archiveNamePrefix)
        {
            var archiveFilesName = FileSystemProxy.EnumerateFiles(_archiveFolderPath, archiveNamePrefix + "*", SearchOption.AllDirectories)
                                   .OrderByDescending(x => ExtractDateTime(x, archiveNamePrefix))
                                   .First();

            var archiveContent = await GetArchiveContentAsync <TValue>(archiveFilesName);

            return(archiveContent);
        }
Exemplo n.º 3
0
        internal async Task <Dictionary <string, TValue> > MergeArchivesAsync <TValue>(string archiveNamePrefix)
        {
            var archiveFilesNames = FileSystemProxy.EnumerateFiles(_archiveFolderPath, archiveNamePrefix + "*", SearchOption.AllDirectories)
                                    .OrderBy(x => ExtractDateTime(x, archiveNamePrefix));

            var mergedArchivesContent = new Dictionary <string, TValue>();

            foreach (var filesName in archiveFilesNames)
            {
                var archiveContent = await GetArchiveContentAsync <TValue>(filesName);

                foreach (var item in archiveContent)
                {
                    mergedArchivesContent[item.Key] = item.Value;
                }
            }

            return(mergedArchivesContent);
        }