Example #1
0
        public IEnumerable <PackageVerifierIssue> Validate(PackageAnalysisContext context)
        {
            if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
            {
                throw new InvalidOperationException("Package sign verification is only supported on Windows machines");
            }

            var args = new[]
            {
                "verify",
                "-NonInteractive",
                "-All",
                context.PackageFileInfo.FullName,
            };

            var psi = new ProcessStartInfo
            {
                FileName  = _nuGetExePath,
                Arguments = ArgumentEscaper.EscapeAndConcatenate(args),
                RedirectStandardOutput = true,
            };

            var process = Process.Start(psi);

            process.WaitForExit(60 * 1000);

            if (process.ExitCode != 0)
            {
                var issueText = process.StandardOutput.ReadToEnd();
                yield return(PackageIssueFactory.PackageSignVerificationFailed(context.Metadata.Id, issueText));
            }
        }