Exemplo n.º 1
0
        private void Save()
        {
            if (Options.FullCompile)
            {
                var bindingsAssemblyPath = bindingCompiler.OutputFileName;
                bindingCompiler.SaveAssembly();

                Program2.WriteInfo($"Bindings saved to {bindingsAssemblyPath}.");

                compilation = compilation.AddReferences(MetadataReference.CreateFromFile(Path.GetFullPath(bindingsAssemblyPath)));
                var compiledViewsFileName = Path.Combine(Options.OutputPath, Options.AssemblyName + ".dll");

                var result = compilation.Emit(compiledViewsFileName);
                if (!result.Success)
                {
                    throw new Exception("The compilation failed!");
                }
                Program2.WriteInfo($"Compiled views saved to {compiledViewsFileName}.");
            }
        }
Exemplo n.º 2
0
 private void Save()
 {
     if (Options.FullCompile)
     {
         var bindingsAssemblyPath = bindingCompiler.OutputFileName;
         bindingCompiler.SaveAssembly();
         Program.WriteInfo("bindings saved to " + bindingsAssemblyPath);
         compilation = compilation.AddReferences(MetadataReference.CreateFromFile(Path.GetFullPath(bindingsAssemblyPath)));
         var compiledViewsFileName = Path.Combine(Options.OutputPath, Options.AssemblyName + ".dll");
         //Directory.CreateDirectory("outputCS");
         //int i = 0;
         //foreach (var tree in compilation.SyntaxTrees)
         //{
         //    File.WriteAllText($"outputCS/file{i++}.cs", tree.GetRoot().NormalizeWhitespace().ToString());
         //}
         var result = compilation.Emit(compiledViewsFileName);
         if (!result.Success)
         {
             throw new Exception("compilation failed");
         }
         Program.WriteInfo("views saved to " + compiledViewsFileName);
     }
 }