IEnumerable <VersionVertex> CreateVersionVertices() { if (Version != null) { foreach (var vertice in NuSpecConverter.ConvertNuGetVersionRange(Version).DefaultIfEmpty(new AnyVersionVertex())) { yield return(vertice); } yield break; } Version version = null; if (!string.IsNullOrEmpty(ExactVersion) && (version = ExactVersion.ToVersion()) != null) { yield return(new EqualVersionVertex(version)); } if (!string.IsNullOrEmpty(MinVersion) && (version = MinVersion.ToVersion()) != null) { yield return(new GreaterThanOrEqualVersionVertex(version)); } if (!string.IsNullOrEmpty(MaxVersion) && (version = MaxVersion.ToVersion()) != null) { yield return(new LessThanVersionVertex(version)); } }
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.ToVersion())); } if (MinVersion != null) { builder = builder.VersionVertex(new GreaterThanOrEqualVersionVertex(MinVersion.ToVersion())); } if (MaxVersion != null) { builder = builder.VersionVertex(new LessThanVersionVertex(MaxVersion.ToVersion())); } return(builder); }
IEnumerable <ICommandOutput> ValidateInputs() { var gotVersion = Version != null; var gotMinVersion = MinVersion != null; var gotMaxVersion = MaxVersion != null; var numberOfVersionInputTypes = (new[] { gotVersion, (gotMinVersion || gotMaxVersion) }).Count(v => v); if (numberOfVersionInputTypes > 1) { yield return(new Error("Arguments for 'version' and 'version boundaries' cannot be combined.")); yield break; } if (gotVersion && Version.ToVersion() == null) { yield return(new Error("Could not parse version: " + Version)); yield break; } if (gotMinVersion && MinVersion.ToVersion() == null) { yield return(new Error("Could not parse minversion: " + MinVersion)); yield break; } if (gotMaxVersion && MaxVersion.ToVersion() == null) { yield return(new Error("Could not parse maxversion: " + MaxVersion)); yield break; } if (Project && HostEnvironment.ProjectRepository == null) { yield return(new Error("Project repository doesn't exist but -project has been specified.")); yield break; } if (!string.IsNullOrEmpty(Scope) && !Project) { yield return(new Error("Cannot specify a scope when adding to a system package.")); yield break; } }
IEnumerable <ICommandOutput> ValidateInputs() { _dependency = FindDependencyByName(); if (_dependency == null) { yield return(new Error("Dependency not found: " + Name)); yield break; } var gotVersion = Version != null; var gotMinVersion = MinVersion != null; var gotMaxVersion = MaxVersion != null; var numberOfVersionInputTypes = (new[] { gotVersion, (gotMinVersion || gotMaxVersion), AnyVersion }).Count(v => v); if (numberOfVersionInputTypes > 1) { yield return(new Error("Arguments for 'version', 'version boundaries' and 'anyVersion' cannot be combined.")); yield break; } if (gotVersion && Version.ToVersion() == null) { yield return(new Error("Could not parse version: " + Version)); yield break; } if (gotMinVersion && MinVersion.ToVersion() == null) { yield return(new Error("Could not parse minversion: " + MinVersion)); yield break; } if (gotMaxVersion && MaxVersion.ToVersion() == null) { yield return(new Error("Could not parse maxversion: " + MaxVersion)); yield break; } }