예제 #1
0
        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.ToSemVer() == null)
            {
                yield return(new Error("Could not parse version: " + Version));

                yield break;
            }

            if (gotMinVersion && MinVersion.ToSemVer() == null)
            {
                yield return(new Error("Could not parse minversion: " + MinVersion));

                yield break;
            }

            if (gotMaxVersion && MaxVersion.ToSemVer() == 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;
            }
        }
예제 #2
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()));
            }
            if (Edge)
            {
                builder = builder.Edge();
            }
            return(builder);
        }