internal static void Register(CommandLineApplication app, Func <ILogger> getLogger, Action <LogLevel> setLogLevel, Func <IVerifyCommandRunner> getCommandRunner) { app.Command("verify", verifyCmd => { CommandArgument packagePaths = verifyCmd.Argument( "<package-paths>", Strings.VerifyCommandPackagePathDescription, multipleValues: true); CommandOption all = verifyCmd.Option( "--all", Strings.VerifyCommandAllDescription, CommandOptionType.NoValue); CommandOption fingerPrint = verifyCmd.Option( "--certificate-fingerprint", Strings.VerifyCommandCertificateFingerprintDescription, CommandOptionType.MultipleValue); CommandOption verbosity = verifyCmd.Option( "-v|--verbosity", Strings.Verbosity_Description, CommandOptionType.SingleValue); verifyCmd.HelpOption(XPlatUtility.HelpOption); verifyCmd.Description = Strings.VerifyCommandDescription; verifyCmd.OnExecute(async() => { ValidatePackagePaths(packagePaths); VerifyArgs args = new VerifyArgs(); args.PackagePaths = packagePaths.Values; args.Verifications = all.HasValue() ? new List <Verification>() { Verification.All } : new List <Verification>() { Verification.Signatures }; args.CertificateFingerprint = fingerPrint.Values; args.Logger = getLogger(); setLogLevel(XPlatUtility.MSBuildVerbosityToNuGetLogLevel(verbosity.Value())); var runner = getCommandRunner(); var verifyTask = runner.ExecuteCommandAsync(args); await verifyTask; return(verifyTask.Result); }); }); }
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); }
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)); }
public async Task <ActionResult <Teacher> > ChangeIsVerified(VerifyArgs args) { if (args is { })