Пример #1
0
 public static string PublicKeyTokenAsString(this X509Certificate cert)
 {
     string tempfile = Path.GetTempFileName() + ".cer";
     File.WriteAllBytes(tempfile, cert.RawData);
     ProcessUtility pktExtract = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("pktExtract.exe"));
     pktExtract.Exec("-nologo -quiet {0}", tempfile);
     string publicKeyToken = pktExtract.StandardOut.Trim();
     File.Delete(tempfile);
     return publicKeyToken;
 }
Пример #2
0
        public override bool Sign(string file)
        {
            var p = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("signtool.exe"));

            var ret = p.Exec(@"sign /a /f ""{0}"" /p {1} /t {2} ""{3}""", pfxFile, password, "http://timestamp.verisign.com/scripts/timstamp.dll", Path.GetFileName(file));

            if (ret != 0)
            {
                Console.WriteLine(p.StandardError);
                return false;
            }

            return true;
        }
Пример #3
0
        public ToolInfo Identify(string executablePath)
        {
            var result = new ToolInfo();
            executablePath = executablePath.GetFullPath();
            var key = executablePath.Replace("\\", "/");

            var vendor = _settings[key, "Vendor"].StringValue;
            if (string.IsNullOrEmpty(vendor)) {
                var peInfo = PEInfo.Scan(executablePath);

                if (!string.IsNullOrEmpty(peInfo.VersionInfo.CompanyName)) {
                    if (peInfo.VersionInfo.CompanyName.Contains("Microsoft")) {
                        result = IdentifyMicrosoftProduct(peInfo);
                    }
                } else {
                    // hmm. not embedding info. bad developer. no cookie!
                    if ((from di in peInfo.DependencyInformation where di.Filename.Contains("cygwin1") select di).Any()) {
                        var pi = new ProcessUtility(executablePath);
                        pi.Exec("-dumpversion");
                        var ver = pi.StandardOut.Split('.');
                        if (ver.Length > 1 && ver.Length < 4) {
                            result.MajorVersion = ver[0].ToInt32(0);
                            result.MinorVersion = ver[1].ToInt32(0);
                            if (result.MajorVersion > 0) {
                                result.Vendor = ToolVendor.Cygwin;
                            }
                        }
                    }
                }

                if (result.Vendor != ToolVendor.Unknown) {
                    _settings[key, "Vendor"].StringValue = result.Vendor.ToString();
                    _settings[key, "MajorVersion"].IntValue = result.MajorVersion;
                    _settings[key, "MinorVersion"].IntValue = result.MinorVersion;
                    _settings[key, "Type"].SetEnumValue(result.Type);
                }
            } else {
                Enum.TryParse(vendor, true, out result.Vendor);
                result.MajorVersion = _settings[key, "MajorVersion"].IntValue;
                result.MinorVersion = _settings[key, "MinorVersion"].IntValue;
                result.Type = _settings[key, "Type"].GetEnumValue<ToolType>();
            }

            return result;
        }
        /// <summary>
        ///     The (non-static) startup method 
        /// </summary>
        /// <param name="args">
        /// The command line arguments.
        /// </param>
        /// <returns>
        ///     Process return code.
        /// </returns>
        private int Startup(string[] args)
        {
            var options = args.Switches();
            var parameters = args.Parameters();

            foreach (var arg in options.Keys) {
                var argumentParameters = options[arg];

                switch (arg) {
                        /* global switches */
                    case "load-config":
                        // all ready done, but don't get too picky.
                        break;

                    case "nologo":
                        this.Assembly().SetLogo(string.Empty);
                        break;

                    case "help":
                        return Help();

                    case "rescan-tools":
                        ProgramFinder.IgnoreCache = true;
                        break;

                    case "temp-path":
                        Directory.CreateDirectory(Path.GetFullPath(argumentParameters.Last()));
                        Environment.SetEnvironmentVariable("TMP", Path.GetFullPath(argumentParameters.Last()));
                        break;

                    case "output-path":
                        outputPath = Path.GetFullPath(argumentParameters.Last());
                        Directory.CreateDirectory(outputPath);
                        Environment.CurrentDirectory = outputPath;

                        break;

                    case "show-tools":
                        showTools = true;
                        break;

                    case "no-cleanup":
                        noCleanup = true;
                        break;

                    case "no-cleanup-libs":
                        noCleanupLibs = true;
                        break;

                    case "arch":
                        arch = argumentParameters.Last();
                        if(arch == "x64")
                            arch = "amd64";

                        break;

                    default:
                        if( arg.StartsWith("exe-") ) {
                            var appname = arg.Substring(4);

                            var t = AddEXE(GetItemName(appname), GetItemVersion(appname));
                            t.Ignore = false;
                            foreach( var item in argumentParameters) {
                                t.Dependencies.Add(AddDLL(GetItemName(item), GetItemVersion(item)));
                            }
                            break;
                        }

                        if( arg.StartsWith("dll-")) {
                            var dllname = arg.Substring(4);

                            var t = AddDLL(GetItemName(dllname), GetItemVersion(dllname));
                            t.Ignore = false;
                            foreach(var item in argumentParameters) {
                                if(!String.IsNullOrEmpty(item) )
                                    t.Dependencies.Add(AddDLL(GetItemName(item), GetItemVersion(item)));
                            }
                            break;
                        }

                        if( arg.StartsWith("policy-")) {
                            var dllname = arg.Substring(7);
                            var t = AddDLL(GetItemName(dllname), GetItemVersion(dllname));

                            foreach(var policyText in argumentParameters) {
                                var policy = policyText.Split('-');
                                t.Policies.Add(new Tuple<string, string>(policy[0], policy.Length == 2 ? policy[1]: policy[0]));
                            }
                            break;
                        }

                        return Fail("Unknown parameter [--{0}]", arg);
                }
            }

            Logo();

            if (parameters.Count() > 0) {
                return Fail("Unknown Command line. \r\n\r\n    Use --help for command line help.");
            }

            var target_cpu = Environment.GetEnvironmentVariable("TARGET_CPU");
            if( string.IsNullOrEmpty(target_cpu) || (target_cpu == "x64" && arch =="x86") || (target_cpu == "x86" && arch != "x86" ) ) {
                var setEnv = ProgramFinder.ProgramFiles.ScanForFile("setenv.cmd");
                if (string.IsNullOrEmpty(setEnv))
                    return Fail("Cannot locate SDK SetEnv command. Please install the Windows SDK");

                var se = new ProcessUtility("cmd.exe");
                se.Exec(@"/c ""{0}"" /{1} & set ",setEnv, arch == "x86"?"x86":"x64");

                foreach( var x in se.StandardOut.Split("\r\n".ToCharArray(),StringSplitOptions.RemoveEmptyEntries)  )
                    if (x.Contains("=")) {
                        var v = x.Split('=');
                        Environment.SetEnvironmentVariable(v[0],v[1]);
                    }

                target_cpu = Environment.GetEnvironmentVariable("TARGET_CPU");
                if (string.IsNullOrEmpty(target_cpu) || (target_cpu == "x64" && arch == "x86") || (target_cpu == "x86" && arch != "x86")) {
                    return Fail("Cannot set the SDK environment. Please install the Windows SDK and use the setenv.cmd command to set your environment");
                }
            }
            Console.WriteLine("[Looking up tool locations...]");

            pktExtract = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("pktExtract.exe"));
            signTool = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("signTool.exe"));

            cl_x86 = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("cl.exe", ExecutableInfo.x86, new[] { @"*\x86_amd64\*" ,@"*\x86_ia64\*"}));
            cl_x64 = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("cl.exe", ExecutableInfo.x64));

            lib_x86 = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("lib.exe", ExecutableInfo.x86, new[] { @"*\x86_amd64\*", @"*\x86_ia64\*" }));
            lib_x64 = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("lib.exe", ExecutableInfo.x64));

            mt = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("mt.exe"));
            certMgr = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("certMgr.exe"));

            makecat = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("makecat.exe"));

            autoPackage = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("autopackage.exe"));
            cmd = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("cmd.exe"));

            cl = arch == "x86" ? cl_x86 : cl_x64;
            lib = arch == "x86" ? lib_x86 : lib_x64;

            if( showTools ) {
                Console.WriteLine( pktExtract.Executable );
                Console.WriteLine(signTool.Executable);
                Console.WriteLine(cl.Executable);
                Console.WriteLine(mt.Executable);
                Console.WriteLine(certMgr.Executable);
                Console.WriteLine(lib.Executable);
                Console.WriteLine(makecat.Executable);
                Console.WriteLine(autoPackage.Executable);
                Console.WriteLine(cmd.Executable);
            }

            signingCertPath  = Assembly.GetExecutingAssembly().ExtractFileResourceToTemp("CoAppTest.pfx");
            cleanupFiles.Add(signingCertPath);

            // ensure certificate is installed.
            InstallCertificate();

            try {

                foreach (var dll in sharedLibraryTargets) {
                    CreateDLL(dll);
                }

                foreach (var exe in applicationTargets) {
                    CreateEXE(exe);
                }

                if (!noCleanup)
                    foreach (var file in cleanupFiles)
                        if (File.Exists(file))
                            File.Delete(file);

            }
            catch (Exception e) {
                return Fail(e.Message);
            }

            return 0;
        }
Пример #5
0
        private int main(string[] args)
        {
            var options = args.Switches();
            var parameters = new List<string>(args.Parameters());

            #region Parse Options

            foreach(var arg in options.Keys) {

                var argumentParameters = (IList<string>)options[arg];

                switch(arg) {
                        /* options  */

                    case "output-file":
                        this._outputFile = argumentParameters[0];
                        break;

                        /* global switches */
                    case "load-config":
                        // all ready done, but don't get too picky.
                        break;

                    case "nologo":
                        this.Assembly().SetLogo("");
                        break;

                    case "help":
                        return Help();

                    case "ignore-signing":
                        this._ignoreSigning = true;
                        break;

                    case "dont-create-msi":
                        this._dontCreateMsi = true;
                        break;

                    case "output-idized-spec":
                        this._outputIDizedSpec = true;
                        break;
                    case "dont-sign-msi":
                        this._dontSignMsi = true;
                        break;

                    case "pfx-file":
                        this._pfxFile = argumentParameters[0];
                        break;

                    case "pfx-password":
                        this._pfxPassword = argumentParameters[0];
                        break;

                    case "show-tools":
                        this._showTools = true;
                        break;

                    default:
                        return Fail("Unknown parameter [--{0}]", arg);
                }
            }
            Logo();

            #endregion

            /*
            if(parameters.Count != 1) {

                return Fail("Missign source code root path. \r\n\r\n    Use --help for command line help.");
            }*/

            Console.WriteLine("Looking up tool locations...");

            _candle = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("candle.exe"));
            _light = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("light.exe"));

            if (_candle.Executable == null)
                return Fail("candle.exe from WiX could not be found. Are you sure it's installed?");

            if (_light.Executable == null)
                return Fail("light.exe from WiX could not be found. Are you sure it's installed?");

            if (_showTools)
            {
                Console.WriteLine(_candle.Executable);
                Console.WriteLine(_light.Executable);
            }

            Console.WriteLine("Running mkPackage on: {0}", parameters[0]);
            //XmlDocument specFile = null;
            Package p = null;
            var xs = new XmlSerializer(typeof(Package));
            try
            {
                using (var r = new StreamReader(parameters[0]))
                {
                    p = (Package)xs.Deserialize(r);
                }
            }
            catch (IOException)
            {
                return Fail("Package specification file couldn't be opened.");
            }
            catch (InvalidOperationException e)
            {
                if (e.InnerException.GetType() == typeof(XmlException))
                {
                    return Fail("There was a problem with the syntax of your file. The error is as follows: {0}",
                                e.InnerException.Message);
                }

                return Fail("There was an unspecified problem with the file.");
            }
            catch (Exception e)
            {
                return Fail("There was an unspecified problem with the file.");
            }

            var idizer = new IDizer(p);
            if (_outputFile == null)
            {
                _outputFilePre = String.Format("{0}-{1}-{2}", p.Name,p.Version, p.Arch);
                _outputFile = _outputFilePre + ".msi";
            }

            if (!idizer.addIDs())
                return Fail("There was a problem with your XML syntax.");

            //Verify that all binary files have signatures and assms are signed by the inputted PFX
            if (!this._ignoreSigning)
            {
                //TODO: Verifying x64 binaries does not work... also we don't/can't verify .cat files
                var pfxVerifier = new PKCSVerifier(this._pfxFile, this._pfxPassword);
                if (p.Arch != Arch.x64 && (!pfxVerifier.VerifyAssemblies(idizer.CollectAssmFiles()) ||
                    !pfxVerifier.VerifyNonAssemblies(idizer.CollectBinFiles())))
                    return Fail("File signatures could not be verified. Make sure your binary files (.EXE, .DLL, .OCX, etc.) are digitally signed.");
            }

            //convert package back to xml!
            var specFile = new XmlDocument();

            StringBuilder memoryStream = null;
            try
            {

                memoryStream = new StringBuilder();
                var xw = XmlWriter.Create(memoryStream);

                xs.Serialize(xw, p);
                xw.Flush();

                specFile.LoadXml(memoryStream.ToString());

                if (_outputIDizedSpec)
                {
                    using (var streamwriter = new StreamWriter(_outputFilePre + "spec.xml", false))
                    {
                        streamwriter.Write(memoryStream);
                    }
                }

            }
            catch (Exception e)
            {
                return Fail("Internal failure converting back to XML " +
                    Environment.NewLine +
                    "Exception type: {0}; Message:{1}", e.GetType().Name, e.Message);

            }

            //author wix
            var tempPrefix = Path.GetTempFileName();
            var xslArgs = new XsltArgumentList();
            xslArgs.AddParam("bootstrap-src", "", tempPrefix + "bootstrap.exe");
            using (var fs = System.IO.File.Create(tempPrefix + "bootstrap.exe"))
            {
                fs.Write(Properties.Resources.coapp_bootstrap, 0, Properties.Resources.coapp_bootstrap.Length);
            }

            var transform = new XslCompiledTransform(true);
            using (TextReader tr = new StringReader(CoApp.mkPackage.Properties.Resources.PkgToWix))
            {
                using (var r = XmlReader.Create(tr))
                {
                    transform.Load(r);
                }
            }

            tempPrefix = Path.GetTempFileName();
            using (var fs = System.IO.File.Create(tempPrefix + ".wxs", 8192))
            {

                transform.Transform(specFile, xslArgs, fs);
            }
            //create MSI

            if (!_dontCreateMsi)
            {

                //we suppress the lack of UpgradeCode warning since we don't use them
                int ret = _candle.Exec("-nologo -sw1075 -out {0}.wixobj {0}.wxs", tempPrefix);

                if (ret != 0)
                    return Fail("Candle failed. Something screwy is going on." + Environment.NewLine + _candle.StandardOut);

                //do the compile

                //we suppress the lack of UpgradeCode warning since we don't use them
                ret = _light.Exec("-nologo -sw1076 -out {1} {0}.wixobj", tempPrefix, _outputFile);

                if (ret != 0)
                    return Fail("Light failed. Something screwy is going on." + Environment.NewLine + _light.StandardOut);
            }

            //digitally sign the msi
            if (!_dontCreateMsi && (!_ignoreSigning || !_dontSignMsi ) )
            {
                var s = new PfxSigner(_pfxFile, _pfxPassword);
                if (!s.Sign(_outputFile))
                    return Fail("The MSI couldn't be signed.");
            }

            return 0;
        }
Пример #6
0
        private void Load(string[] args)
        {
            var options = args.Switches();
            var parameters = args.Parameters();

            foreach (var arg in args)
            {
                var argumentParameters = options[arg];

                if (arg.StartsWith("exe-"))
                {
                    var appname = arg.Substring(4);

                    var t = AddEXE(GetItemName(appname), GetItemVersion(appname));
                    t.Ignore = false;
                    foreach (var item in argumentParameters)
                    {
                        t.Dependencies.Add(AddDLL(GetItemName(item), GetItemVersion(item)));
                    }
                    break;
                }

                else if (arg.StartsWith("dll-"))
                {
                    var dllname = arg.Substring(4);

                    var t = AddDLL(GetItemName(dllname), GetItemVersion(dllname));
                    t.Ignore = false;
                    foreach (var item in argumentParameters)
                    {
                        if (!String.IsNullOrEmpty(item))
                            t.Dependencies.Add(AddDLL(GetItemName(item), GetItemVersion(item)));
                    }
                    break;
                }

                else if (arg.StartsWith("policy-"))
                {
                    var dllname = arg.Substring(7);
                    var t = AddDLL(GetItemName(dllname), GetItemVersion(dllname));

                    foreach (var policyText in argumentParameters)
                    {
                        var policy = policyText.Split('-');
                        t.Policies.Add(new Tuple<string, string>(policy[0], policy.Length == 2 ? policy[1] : policy[0]));
                    }
                    break;
                }

            }

            cl_x86 = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("cl.exe", ExecutableInfo.x86, new[] { @"*\x86_amd64\*", @"*\x86_ia64\*" }));
            cl_x64 = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("cl.exe", ExecutableInfo.x64));

            //This only works if
            var cscpf = new ProgramFinder("C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319");
            csc_msil = new ProcessUtility(cscpf.ScanForFile("csc.exe"));
            al_msil = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("al.exe"));

            lib_x86 = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("lib.exe", ExecutableInfo.x86, new[] { @"*\x86_amd64\*", @"*\x86_ia64\*" }));
            lib_x64 = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("lib.exe", ExecutableInfo.x64));

            pktExtract = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("pktExtract.exe"));
        }
Пример #7
0
        private IEnumerable<string> BuildX86()
        {
            clearTargetBuildFlags();
            var output = new List<string>();
            var setEnv = ProgramFinder.ProgramFiles.ScanForFile("setenv.cmd");
            if (string.IsNullOrEmpty(setEnv))
                throw new Exception("Cannot locate SDK SetEnv command. Please install the Windows SDK");

            var se = new ProcessUtility("cmd.exe");
            se.Exec(@"/c ""{0}"" /{1} & set ", setEnv, "x86");

            foreach (var x in se.StandardOut.Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
                if (x.Contains("="))
                {
                    var v = x.Split('=');
                    Environment.SetEnvironmentVariable(v[0], v[1]);
                }

            var target_cpu = Environment.GetEnvironmentVariable("TARGET_CPU");
            if (string.IsNullOrEmpty(target_cpu) || (target_cpu == "x64") )
            {

                    throw new Exception(
                        "Cannot set the SDK environment. Please install the Windows SDK and use the setenv.cmd command to set your environment");
            }

            foreach (var dll in sharedLibraryTargets)
            {
                CreateDLL(dll, "x86", output);
            }

            foreach (var exe in applicationTargets)
            {
                CreateEXE(exe, "x86", output);
            }

            return null;
        }
Пример #8
0
        private IEnumerable<string> BuildMSIL()
        {
            clearTargetBuildFlags();
            var setEnv = ProgramFinder.ProgramFiles.ScanForFile("VSVARS32.bat");
            if (string.IsNullOrEmpty(setEnv))
               throw new Exception("Cannot locate VCVARS32.bat command. Please install something?");

            var se = new ProcessUtility(setEnv);
            se.Exec("");

            return null;
        }
        private static void RebuildSite()
        {
            try
            {
                var cmdexe = new ProcessUtility("cmd.exe");
                Console.WriteLine("Rebuilding website.");
                // update the website now.
                // make a new directory in the e:\sitesroot\<####>
                var path = @"e:\sitesroot\" + DateTime.Now.Ticks.ToString();
                var tmpPath = path + "_";

                Console.WriteLine("Cloning from github");
                cmdexe.Exec(@"/c git.cmd clone git://github.com/coapp/coapp.org.git ""{0}""", tmpPath);

                Environment.CurrentDirectory = tmpPath;

                Console.WriteLine("Running Jekyll");
                cmdexe.Exec(@"/c jekyll.bat e:\sitesroot\0");

                Environment.CurrentDirectory = @"e:\sitesroot";

                cmdexe.Exec(@"/c rmdir /s /q ""{0}""", tmpPath);

                /*
                                Console.WriteLine("Updating Links");
                                var oldSite = Symlink.GetActualPath(@"e:\sitesroot\0");
                                Symlink.ChangeLinkTarget(@"e:\sitesroot\0", path);

                                Console.WriteLine("Old Site Removal [{0}]", oldSite);
                                cmdexe.Exec(@"/c rmdir /s /q ""{0}""", tmpPath);
                                cmdexe.Exec(@"/c rmdir /s /q ""{0}""", oldSite);
                                */
                Console.WriteLine("Done.");
            } catch (Exception e )
            {
                Console.WriteLine("Rebuild Site: {0}", e.Message);
                Console.WriteLine("              {0}", e.StackTrace);
            }
        }
Пример #10
0
        private int Startup(IEnumerable<string> args)
        {
            _signingCertPath = QuickSettings.EncryptedStringSetting["SigningCertPath"];

            ReadPassword();

            var options = args.Switches();
            var parameters = args.Parameters();

            foreach (var arg in options.Keys) {
                var argumentParameters = options[arg];

                switch (arg) {
                        /* global switches */
                    case "load-config":
                        // all ready done, but don't get too picky.
                        break;

                    case "nologo":
                        this.Assembly().SetLogo(string.Empty);
                        break;

                    case "help":
                        return Help();

                    case "rescan-tools":
                        ProgramFinder.IgnoreCache = true;
                        break;

                    case "certificate-path":
                        _signingCertPath = Path.GetFullPath(argumentParameters.Last());
                        ReadPassword();
                        break;

                    case "password":
                        _signingCertPassword = argumentParameters.Last();
                        break;

                    case "remember":
                        _remember = true;
                        break;

                    case "show-tools":
                        _showTools = true;
                        break;

                    case "sign-only":
                        _strongname = false;
                        break;

                    case "name-only":
                        _sign = false;
                        break;

                    case "verbose":
                        _verbose = true;
                        break;

                    default:
                        return Fail("Unknown parameter [--{0}]", arg);
                }
            }

            Logo();

            if (parameters.Count() < 1) {
                return Fail("Missing files to sign/name. \r\n\r\n    Use --help for command line help.");
            }

            if (_remember) {
                QuickSettings.EncryptedStringSetting["SigningCertPath"] = _signingCertPath;
                QuickSettings.EncryptedStringSetting["SigningCertPassword:"******"[Looking up tool locations...]");

            _signTool = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("signTool.exe"));
            _strongNameTool = new ProcessUtility(ProgramFinder.ProgramFilesAndDotNet.ScanForFile("sn.exe"));

            if (_showTools) {
                Console.WriteLine(_signTool.Executable);
                Console.WriteLine(_strongNameTool.Executable);
            }

            if (string.IsNullOrEmpty(_signingCertPath) || !File.Exists(_signingCertPath)) {
                Fail("Certificate Path Not Found [{0}] ", _signingCertPath);
            }

            try {
                foreach (var filename in parameters.FindFilesSmarter()) {
                    var result = "";
                    if( CoApp.Toolkit.Crypto.Verifier.HasValidSignature(filename)) {
                        using (new ConsoleColors(ConsoleColor.Yellow, ConsoleColor.Black)) {
                            Console.WriteLine("[{0}] already has a valid signature; skipping.", filename);
                        }
                        continue;
                    }

                    if (_strongname) {
                        _strongNameTool.ExecAsyncNoStdInRedirect(NamingCommand, filename, _signingCertPath);
                        _strongNameTool.AttachToConsoleForProcess();
                        result = _strongNameTool.StandardOut + _strongNameTool.StandardError;
                        _strongNameTool.WaitForExit(200);

                        if (!_strongNameTool.IsRunning) {
                            if (result.Contains("Failed to")) {
                                using (new ConsoleColors(ConsoleColor.Red, ConsoleColor.Black)) {
                                    Console.WriteLine("[{0}] failed strong naming; skipping.", filename);
                                }
                            }
                            // finished without waiting for a password. We're skipping this.
                            continue;
                        }

                        // send the password!
                        ConsoleApi.SendStringToStdIn(_signingCertPassword + "\r");
                        _strongNameTool.WaitForExit();

                        result += _strongNameTool.StandardOut + _strongNameTool.StandardError;
                        if (result.Contains("Failed to")) {
                            using (new ConsoleColors(ConsoleColor.Red, ConsoleColor.Black)) {
                                Console.WriteLine("[{0}] failed strong naming; skipping.", filename);
                            }
                            continue;
                        }

                        if (result.Contains("successfully re-signed")) {
                            using (new ConsoleColors(ConsoleColor.Green, ConsoleColor.Black)) {
                                Console.WriteLine("[{0}] Strong Named Successfully.", filename);
                            }
                        }

                        Verbose(Filter(result));
                    }

                    if (_sign) {
                        _signTool.Exec(SigningCommand, _signingCertPath, _signingCertPassword, filename);
                        result = _signTool.StandardOut + _signTool.StandardError;
                        if (result.Contains("Successfully signed and timestamped")) {
                            using (new ConsoleColors(ConsoleColor.Green, ConsoleColor.Black)) {
                                Console.WriteLine("[{0}] Digitally Signed and Timestamped Successfully.", filename);
                            }
                        }
                        else {
                            using (new ConsoleColors(ConsoleColor.Red, ConsoleColor.Black)) {
                                Console.WriteLine("[{0}] failed digital signing.", filename);
                            }
                        }
                        Verbose(Filter(result));
                    }
                }
            }
            catch (Exception e) {
                return Fail(e.Message);
            }

            return 0;
        }