示例#1
0
        private void BG_DoWork(object sender, DoWorkEventArgs e)
        {
            string ErrorText;
            string DLLFilename;

            PackageCompiler = new PackageCompiler();
            PackageCompiler.OnStatusUpdate += PackageCompiler_OnStatusUpdate;
            if (PackageCompiler.CheckScript(Package, out ErrorText) == false)
            {
                e.Result = ErrorText;
                e.Cancel = false;
                Debug.WriteLine("BG_DoWork() canceled");
                return;
            }

            if (PackageCompiler.CompileScript(Package.Script, out ErrorText, "", out DLLFilename) == null)
            {
                e.Result = ErrorText;
                e.Cancel = false;
                Debug.WriteLine("BG_DoWork() canceled (Compiler)");
                return;
            }

            if (PackageCompiler.CompilePackage(Package, (PKGCompilerArgs)e.Argument, out ErrorText) == false)
            {
                e.Result = ErrorText;
                e.Cancel = false;
                Debug.WriteLine("BG_DoWork() canceled (2)");
                return;
            }
            e.Cancel = false;
            e.Result = true;
            Debug.WriteLine("BG_DoWork() done");
        }
示例#2
0
        static int Main(string[] args)
        {
            if (args.Length < 1)
            {
                Help();
                return(1);
            }

            switch (args[0].ToLower())
            {
            case "-?":
            case "/?":
            case "/h":
            case "-h":
            case "?":
                Help();
                return(1);

            case "listcerts":
            {
                Console.WriteLine("Available certificates:");
                foreach (string s in Certificates.GetCertificates(StoreLocation.CurrentUser))
                {
                    Console.WriteLine("  " + s);
                }
                Console.WriteLine("Available CSPs:");

                foreach (string s in SmartCards.GetCSPProviders())
                {
                    Console.WriteLine("  " + s);
                }
                return(0);
            }

            case "compile":
            {
                if (args.Length < 4)
                {
                    Console.WriteLine("Insufficient argurments.");
                    return(1);
                }
                string     filename = args[1];
                CertMethod certmeth = CertMethod.UNKNOWN;
                switch (args[2].ToLower())
                {
                case "cert":
                    certmeth = CertMethod.CERT;
                    break;

                case "csp":
                    certmeth = CertMethod.CSP;
                    break;
                }
                if (certmeth == CertMethod.UNKNOWN)
                {
                    Console.WriteLine("Unknown certificate method.");
                    return(1);
                }
                string certname = args[3];

                PKGCompilerArgs pkgcompiler = new PKGCompilerArgs();
                pkgcompiler.UseExtSign   = certmeth == CertMethod.CSP ? true : false;
                pkgcompiler.SignCert     = certname;
                pkgcompiler.SignExtCert  = certname;
                pkgcompiler.SignLocation = StoreLocation.CurrentUser;
                pkgcompiler.PIN          = null;

                string          ErrorText;
                PackageCompiler PackageCompiler = new PackageCompiler();
                PackageCompiler.OnStatusUpdate += PackageCompiler_OnStatusUpdate;
                bool res = PackageCompiler.CompilePackage(filename, pkgcompiler, out ErrorText);
                if (res == false)
                {
                    Console.WriteLine("\n" + ErrorText + "\n\nFAILED!\n");
                    return(5);
                }
                Console.WriteLine("Success");
                return(0);
            }

            default:
            {
                Console.WriteLine("Unsupported command");
                break;
            }
            }

            return(1);
        }