public static void Main(string[] args) { if (AppDomain.CurrentDomain.IsDefaultAppDomain()) { // RazorEngine cannot clean up from the default appdomain... //Console.WriteLine("Switching to second AppDomain..."); AppDomainSetup adSetup = new AppDomainSetup(); adSetup.ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase; var current = AppDomain.CurrentDomain; // You only need to add strongnames when your appdomain is not a full trust environment. var strongNames = new StrongName[0]; var domain = AppDomain.CreateDomain( "MyMainDomain", null, current.SetupInformation, new PermissionSet(PermissionState.Unrestricted), strongNames); try { domain.ExecuteAssembly(Assembly.GetExecutingAssembly().Location, args); } catch (Exception ex) { Console.WriteLine("Error executing ContrastDvnr: " + ex.Message); Trace.TraceError("Error executing ContrastDvnr: " + ex); return; } return; } var traceOutput = new DvnrTraceListener("ContrastDvnr.log", "tracelog"); Trace.Listeners.Add(traceOutput); Trace.AutoFlush = true; var arguments = new Docopt().Apply(usage, args, version: "ContrastDvnr 1.0", exit: true); Trace.TraceInformation("ContrastDvnr executed with arguments [{0}]", string.Join(" ", args)); // ensure IIS is installed and we can use ServerManager if (!Reporting.PreFlightCheck()) { return; } bool isXml = arguments["xml"].IsTrue; bool isJson = arguments["json"].IsTrue; bool isText = arguments["text"].IsTrue; ReportFileType reportType = ReportFileType.Unknown; // default to xml if no format is specified if (!isXml && !isJson && !isText) { reportType = ReportFileType.Xml; } else if (isXml) { reportType = ReportFileType.Xml; } else if (isJson) { reportType = ReportFileType.Json; } else if (isText) { reportType = ReportFileType.Text; } string fileName = "report.xml"; if (reportType == ReportFileType.Xml) { fileName = "report.xml"; } else if (reportType == ReportFileType.Json) { fileName = "report.json"; } else if (reportType == ReportFileType.Text) { fileName = "report.txt"; } DvnrReport report; string fromFilename = arguments.ContainsKey("--from") ? arguments["--from"]?.ToString() : ""; if (!string.IsNullOrEmpty(fromFilename)) { report = GenerateReportFromExisting(fromFilename, reportType); } else { report = GenerateReportFromCurrentMachine(); } string directory = CreateOutputDirectory(); if (arguments["--screen"].IsTrue) // write to screen instead of file { if (reportType == ReportFileType.Xml) { PrintReportXml(report, Console.Out); } if (reportType == ReportFileType.Json) { PrintReportJson(report, Console.Out); } if (reportType == ReportFileType.Text) { PrintReportText(report, Console.Out); } } else { // write to file string dvnrReportPath = Path.Combine(directory, fileName); Console.WriteLine("Writing DVNR report."); WriteDvnrReportFile(reportType, dvnrReportPath, report); string compatReportPath = Path.Combine(directory, "compatSummary.md"); Console.WriteLine("Writing compatibility report."); WriteCompatSummary(report, compatReportPath); } Trace.TraceInformation("ContrastDvnr exited"); Trace.Flush(); }
static void Main(string[] args) { var arguments = new Docopt().Apply(UsagePatterns, args, version: Assembly.GetExecutingAssembly().GetName().Version, exit: true); if (arguments.ContainsKey("<target_dll>")) { foreach (ValueObject targetDll in (ArrayList)arguments["<target_dll>"].Value) { string assmPath = (string)targetDll.Value; if (File.Exists(assmPath)) { // grab dest path if provided string destPath = null; if (arguments["--dest"] != null && arguments["--dest"].IsString) { destPath = (string)arguments["--dest"].Value; } Console.WriteLine($"target path is {destPath}"); // grab search paths if provided string[] searchPaths = null; if (arguments["--search"] != null && arguments["--search"].IsList) { List <string> lookupPaths = new List <string>(); foreach (ValueObject searchPath in arguments["--search"].AsList.ToArray()) { Console.WriteLine($"search path {searchPath}"); lookupPaths.Add((string)searchPath.Value); } searchPaths = lookupPaths.ToArray(); } // prepare generator configs // grab pre and postfixes for root namespace dir names var genCfg = new BuildConfig { Prefix = arguments["--prefix"] != null ? (string)arguments["--prefix"].Value : string.Empty, Postfix = arguments["--postfix"] != null ? (string)arguments["--postfix"].Value : string.Empty, DestPathIsRoot = arguments["--dest-is-root"] != null ? (bool)arguments["--dest-is-root"].Value : false, }; Console.WriteLine($"building stubs for {assmPath}"); try { var dest = StubBuilder.BuildAssemblyStubs( assmPath, destPath: destPath, searchPaths: searchPaths, cfgs: genCfg ); Console.WriteLine($"stubs saved to {dest}"); } catch (Exception sgEx) { Console.WriteLine($"error: failed generating stubs | {sgEx.Message}"); } } else { Console.WriteLine($"error: can not find {assmPath}"); } } } }