public void RunStep(RuntimeSettings settings, ILog log) { log.Info("Creating epub file from contents..."); FsPath output = settings.OutputDirectory.Combine("book.epub"); FsPath input = settings.OutputDirectory.Combine("epubtemp"); output.WriteFile(log, ""); string[] files = input.GetAllFiles().Select(f => f.ToString()).ToArray(); int removeLength = input.ToString().Length + 1; using (var fs = File.Create(output.ToString())) { using (var zip = new ZipArchive(fs, ZipArchiveMode.Create)) { //note: 1st entry is mimetype. It must not be compressed for correct epub export zip.CreateEntryFromFile(files[0], GetEntryName(files[0], removeLength), CompressionLevel.NoCompression); for (int i = 1; i < files.Length; i++) { zip.CreateEntryFromFile(files[i], GetEntryName(files[i], removeLength), CompressionLevel.Optimal); } } } }
public int LoadScripts(FsPath scriptsDir) { try { var files = scriptsDir.GetAllFiles("*.cs"); IEnumerable <Microsoft.CodeAnalysis.SyntaxTree> trees = _compiler.ParseToSyntaxTree(files); Assembly?assembly = _compiler.CompileToAssembly(trees); if (assembly != null) { int count = SearchAndAddTypes(assembly); return(count); } return(0); } catch (Exception ex) { _log.Warning(ex); return(0); } }