public static IPackageDescriptor Lock(this IPackageDescriptor lockedDescriptor, IEnumerable<IPackageInfo> lockedPackages)
 {
     foreach (var lockedPackage in lockedPackages)
     {
         var existingDep = lockedDescriptor.Dependencies.FirstOrDefault(x => x.Name == lockedPackage.Name);
         PackageDependencyBuilder builder;
         if (existingDep != null)
         {
             lockedDescriptor.Dependencies.Remove(existingDep);
             builder = new PackageDependencyBuilder(existingDep);
         }
         else
         {
             builder = new PackageDependencyBuilder(lockedPackage.Name);
         }
         lockedDescriptor.Dependencies.Add(builder.SetVersionVertices(new[] { new AbsolutelyEqualVersionVertex(lockedPackage.SemanticVersion) }));
     }
     return lockedDescriptor;
 }
Exemple #2
0
 public static IPackageDescriptor Lock(this IPackageDescriptor lockedDescriptor, IEnumerable <IPackageInfo> lockedPackages)
 {
     foreach (var lockedPackage in lockedPackages)
     {
         var existingDep = lockedDescriptor.Dependencies.FirstOrDefault(x => x.Name == lockedPackage.Name);
         PackageDependencyBuilder builder;
         if (existingDep != null)
         {
             lockedDescriptor.Dependencies.Remove(existingDep);
             builder = new PackageDependencyBuilder(existingDep);
         }
         else
         {
             builder = new PackageDependencyBuilder(lockedPackage.Name);
         }
         lockedDescriptor.Dependencies.Add(builder.SetVersionVertices(new[] { new AbsolutelyEqualVersionVertex(lockedPackage.Version) }));
     }
     return(lockedDescriptor);
 }
Exemple #3
0
 PackageDependency UpdatedDependency(PackageDependency dependency)
 {
     var builder = new PackageDependencyBuilder(dependency);
     if (_content.HasValue)
     {
         builder = builder.Content(_content.Value);
     }
     if (_anchored.HasValue)
     {
         builder = builder.Anchored(_anchored.Value);
     }
     if (SomeVersionInputGiven)
     {
         builder = builder.SetVersionVertices(Enumerable.Empty<VersionVertex>());
     }
     if (AnyVersion)
     {
         builder = builder.VersionVertex(new AnyVersionVertex());
     }
     if (Version != null)
     {
         builder = builder.VersionVertex(new EqualVersionVertex(Version.ToSemVer()));
     }
     if (MinVersion != null)
     {
         builder = builder.VersionVertex(new GreaterThanOrEqualVersionVertex(MinVersion.ToSemVer()));
     }
     if (MaxVersion != null)
     {
         builder = builder.VersionVertex(new LessThanVersionVertex(MaxVersion.ToSemVer()));
     }
     return builder;
 }
        static PackageDependency CreateDependency(XmlNode xmlNode)
        {
            var dep = new PackageDependencyBuilder((xmlNode.Attributes["id"] ?? xmlNode.Attributes["id", NuGetConverter.NuSpecSchema]).Value);

            var version = xmlNode.Attributes["version"] ?? xmlNode.Attributes["version", NuGetConverter.NuSpecSchema];
            var minversion = xmlNode.Attributes["minversion"] ?? xmlNode.Attributes["minversion", NuGetConverter.NuSpecSchema];
            var maxversion = xmlNode.Attributes["maxversion"] ?? xmlNode.Attributes["maxversion", NuGetConverter.NuSpecSchema];
            if (minversion != null || maxversion != null)
            {
                if (minversion != null)
                    dep.VersionVertex(new GreaterThanOrEqualVersionVertex(minversion.Value.ToVersion()));
                if (maxversion != null)
                    dep.VersionVertex(new LessThanVersionVertex(maxversion.Value.ToVersion()));
            }
            else
            {
                dep.SetVersionVertices(ConvertNuGetVersionRange(version != null ? version.Value : null).DefaultIfEmpty(new AnyVersionVertex()));
            }
            return dep;
        }