private void cmdCompile_Click(object sender, EventArgs e) { cmdStop.Enabled = true; panelSettings.Enabled = false; Package.Outputfile = txtOutputFilename.Text.Trim(); PKGCompilerArgs comp = new PKGCompilerArgs(); comp.SignCert = lstCert.Text; comp.SignLocation = StoreLocation.CurrentUser; comp.SignExtCert = lstExtSign.Text; comp.UseExtSign = radExtSign.Checked; BG.RunWorkerAsync(comp); }
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); }