/// <summary> /// Main entry point to the CIL extractor. /// Call this to extract a given assembly. /// </summary> /// <param name="layout">The trap layout.</param> /// <param name="assemblyPath">The full path of the assembly to extract.</param> /// <param name="logger">The logger.</param> /// <param name="nocache">True to overwrite existing trap file.</param> /// <param name="extractPdbs">Whether to extract PDBs.</param> /// <param name="trapFile">The path of the trap file.</param> /// <param name="extracted">Whether the file was extracted (false=cached).</param> public static void ExtractCIL(Layout layout, string assemblyPath, ILogger logger, bool nocache, bool extractPdbs, TrapWriter.CompressionMode trapCompression, out string trapFile, out bool extracted) { trapFile = ""; extracted = false; try { var canonicalPathCache = CanonicalPathCache.Create(logger, 1000); var pathTransformer = new PathTransformer(canonicalPathCache); var extractor = new Extractor(false, assemblyPath, logger, pathTransformer); var transformedAssemblyPath = pathTransformer.Transform(assemblyPath); var project = layout.LookupProjectOrDefault(transformedAssemblyPath); using var trapWriter = project.CreateTrapWriter(logger, transformedAssemblyPath.WithSuffix(".cil"), trapCompression, discardDuplicates: true); trapFile = trapWriter.TrapFile; if (nocache || !System.IO.File.Exists(trapFile)) { var cx = extractor.CreateContext(null, trapWriter, null, false); ExtractCIL(cx, assemblyPath, extractPdbs); extracted = true; } } catch (Exception ex) // lgtm[cs/catch-of-all-exceptions] { logger.Log(Severity.Error, string.Format("Exception extracting {0}: {1}", assemblyPath, ex)); } }
/// <summary> /// Main entry point to the CIL extractor. /// Call this to extract a given assembly. /// </summary> /// <param name="layout">The trap layout.</param> /// <param name="assemblyPath">The full path of the assembly to extract.</param> /// <param name="logger">The logger.</param> /// <param name="nocache">True to overwrite existing trap file.</param> /// <param name="extractPdbs">Whether to extract PDBs.</param> /// <param name="trapFile">The path of the trap file.</param> /// <param name="extracted">Whether the file was extracted (false=cached).</param> public static void ExtractCIL(Layout layout, string assemblyPath, ILogger logger, bool nocache, bool extractPdbs, TrapWriter.CompressionMode trapCompression, out string trapFile, out bool extracted) { trapFile = ""; extracted = false; try { var extractor = new Extractor(false, assemblyPath, logger); var project = layout.LookupProjectOrDefault(assemblyPath); using (var trapWriter = project.CreateTrapWriter(logger, assemblyPath + ".cil", true, trapCompression)) { trapFile = trapWriter.TrapFile; if (nocache || !System.IO.File.Exists(trapFile)) { var cx = extractor.CreateContext(null, trapWriter, null); ExtractCIL(cx, assemblyPath, extractPdbs); extracted = true; } } } catch (Exception ex) // lgtm[cs/catch-of-all-exceptions] { logger.Log(Severity.Error, string.Format("Exception extracting {0}: {1}", assemblyPath, ex)); } }