Exemplo n.º 1
0
        public virtual bool VerifyPackage(string packagePath)
        {
            VerifyArgs verifyArgs = new VerifyArgs()
            {
                Verifications          = new VerifyArgs.Verification[] { VerifyArgs.Verification.All },
                PackagePath            = packagePath,
                CertificateFingerprint = new List <string>()
                {
                    TrustedMicrosoftCertFingerprint
                },
                Logger = this.nuGetLogger
            };

            VerifyCommandRunner verifyCommandRunner = new VerifyCommandRunner();
            int result = verifyCommandRunner.ExecuteCommandAsync(verifyArgs).Result;

            return(result == 0);
        }
Exemplo n.º 2
0
        public override Task ExecuteCommandAsync()
        {
            var PackagePath = Arguments[0];

            if (string.IsNullOrEmpty(PackagePath))
            {
                throw new ArgumentException(nameof(PackagePath));
            }

            var verifyArgs = new VerifyArgs()
            {
                Verifications          = GetVerificationTypes(),
                PackagePaths           = new[] { PackagePath },
                CertificateFingerprint = CertificateFingerprint,
                Logger   = Console,
                Settings = Settings
            };

            switch (Verbosity)
            {
            case Verbosity.Detailed:
                verifyArgs.LogLevel = Common.LogLevel.Verbose;
                break;

            case Verbosity.Normal:
                verifyArgs.LogLevel = Common.LogLevel.Information;
                break;

            case Verbosity.Quiet:
                verifyArgs.LogLevel = Common.LogLevel.Minimal;
                break;
            }

            var verifyCommandRunner = new VerifyCommandRunner();
            var result = verifyCommandRunner.ExecuteCommandAsync(verifyArgs).Result;

            if (result > 0)
            {
                throw new ExitCodeException(1);
            }
            return(Task.FromResult(result));
        }