コード例 #1
0
        public void GetLastStablePackagesFromIndex()
        {
            var index = PackageIndex.Load(PackageIndexes.Select(pi => pi.GetMetadata("FullPath")));

            List <ITaskItem> lastStablePackages = new List <ITaskItem>();

            foreach (var latestPackage in LatestPackages)
            {
                var packageId = latestPackage.ItemSpec;

                var          versionString = latestPackage.GetMetadata("Version");
                NuGetVersion nuGetVersion  = null;
                if (versionString == null || !NuGetVersion.TryParse(versionString, out nuGetVersion))
                {
                    Log.LogMessage($"Could not parse version {versionString} for LatestPackage {packageId}, will use latest stable.");
                }

                var latestVersion = (DoNotAllowVersionsFromSameRelease) ? VersionUtility.As2PartVersion(nuGetVersion?.Version) : nuGetVersion?.Version;

                PackageInfo info;
                if (index.Packages.TryGetValue(packageId, out info))
                {
                    IEnumerable <Version> candidateVersions = (latestVersion == null) ? info.StableVersions : info.StableVersions.Where(sv => VersionUtility.As4PartVersion(sv) < latestVersion);
                    if (candidateVersions.Any())
                    {
                        lastStablePackages.Add(CreateItem(latestPackage, candidateVersions.Max()));
                    }
                }
            }

            LastStablePackages = lastStablePackages.ToArray();
        }
コード例 #2
0
ファイル: NuGetUtility.cs プロジェクト: wuwx/arcade
 public static Version GetLatestPatchStableVersionForRelease(this IEnumerable <Version> versions, int eraMajorVersion, int eraMinorVersion)
 {
     return(versions.Where(v => VersionUtility.As2PartVersion(v) == new Version(eraMajorVersion, eraMinorVersion))
            .OrderByDescending(v => v)
            .FirstOrDefault());
 }