private static byte[] PerformCompilation(string assemblyFilename, string rootDir) { // Get the list of assembly paths to reference during compilation. Currently this // is just the main app assembly, so that you can have code-behind classes. // TODO: Reference all the same assemblies that the main app assembly does. Not // certain how to get that info. Might be enough to have the client pass through // via querystring the list of referenced assemblies declared on the <script> tag. var inferredMainAssemblyFilename = InferMainAssemblyFilename(assemblyFilename); var referenceAssemblyFilenames = new List <string>(); if (!string.IsNullOrEmpty(inferredMainAssemblyFilename)) { referenceAssemblyFilenames.Add(inferredMainAssemblyFilename); } using (var ms = new MemoryStream()) { RazorVDomCompiler.CompileToStream( enableLogging: false, rootDir: rootDir, referenceAssemblies: referenceAssemblyFilenames.Select(filename => Path.Combine("bin", "Debug", "netcoreapp1.0", filename)).ToArray(), outputAssemblyName: Path.GetFileNameWithoutExtension(assemblyFilename), outputStream: ms); return(ms.ToArray()); } }
private static byte[] PerformCompilation(string assemblyFilename, string rootDir, IEnumerable <string> additionalReferenceAssemblies) { // Get the total list of assembly paths to reference during compilation var inferredMainAssemblyFilename = InferMainAssemblyFilename(assemblyFilename); var referenceAssemblyFilenames = new List <string>(); if (!string.IsNullOrEmpty(inferredMainAssemblyFilename)) { referenceAssemblyFilenames.Add(inferredMainAssemblyFilename); } referenceAssemblyFilenames.AddRange(additionalReferenceAssemblies); using (var ms = new MemoryStream()) { RazorVDomCompiler.CompileToStream( enableLogging: false, rootDir: rootDir, referenceAssemblies: referenceAssemblyFilenames.Select(filename => Path.Combine(rootDir, "bin", "Debug", "netcoreapp1.0", filename)).ToArray(), outputAssemblyName: Path.GetFileNameWithoutExtension(assemblyFilename), outputStream: ms); return(ms.ToArray()); } }