Q: How can I use RazorGenerator instead of T4 for generating C# files? I'd like to use http://razorgenerator.codeplex.com/ instead of Visual Studio's T4 capabilities to auto-generate C# files/classes based on the code model of my solution. I've successfully done this using EnvDTE with T4, however, I'd like to use something more maintainable and better supported than T4.
I tried using the Template generator via @* Generator: Template *@, but the output from that are C# classes with an Execute function that will generate the templated c# class I needed. How can I get the C# output directly into my solution?

A: Select your cshtml files in your solution, open the properties pane (F4 by default) and enter "RazorGenerator" (no quotes) as the custom tool.  This will generate a C# source file when you build your project.
Edit - to actually execute the generated class as well
This is more difficult and you'll probably not find a prebuilt custom tool like RazorGenerator that will do it for you.  I'd take a look at the RazorGenerator source code to see how they built the custom tooling/extension aspect.  I'd probably go so far as to fork the RazorGenerator code and modify it to suit my needs.
Here's a method that I use to generate a Type from razor markup.  Here's some cruft specific to MVC you can probably ignore (e.g., extra code to add referenced assemblies so the compilation doesn't fail).
private Type CompileRazorView(string virtualPath, FileInfo file, Assembly partialViewAssembly)
        {
            var config = WebConfigurationManager.OpenWebConfiguration("~/Views/web.config");
            var section = config.GetSectionGroup("system.web.webPages.razor") as RazorWebSectionGroup;
            var host = MvcWebRazorHostFactory.CreateHostFromConfig(section, virtualPath);
            var engine = new RazorTemplateEngine(host);
            using (var stream = file.OpenRead())
            {
                using (var reader = new StreamReader(stream))
                {
                    var result = engine.GenerateCode(reader);
                    string code = null;
                    using (var tw = new StringWriter())
                    {
                        CodeProvider.GenerateCodeFromCompileUnit(result.GeneratedCode, tw, new CodeGeneratorOptions());
                        tw.Flush();
                        code = tw.ToString();
                    }
                    var compilerParameters = new CompilerParameters()
                    {
                        MainClass = host.DefaultClassName,
                        GenerateInMemory = true,
                        IncludeDebugInformation = true,
                    };
                    var thisAssembly = Application.GetType().Assembly;
                    var thisAssemblyName = thisAssembly.GetName();
                    var referencedAssemblies = new List<AssemblyName>();
                    referencedAssemblies.Add(thisAssemblyName);
                    referencedAssemblies.Add(partialViewAssembly.GetName());
                    referencedAssemblies.AddRange(partialViewAssembly.GetReferencedAssemblies());
                    foreach (var applicationReference in thisAssembly.GetReferencedAssemblies())
                    {
                        var assembly = Assembly.Load(applicationReference.FullName);
                        referencedAssemblies.Add(assembly.GetName());
                        referencedAssemblies.AddRange(assembly.GetReferencedAssemblies());
                    }
                    var binPath = Path.GetDirectoryName(thisAssemblyName.CodeBase);
                    var distinctReferences = referencedAssemblies.Distinct((a, b) =>
                        string.Equals(a.FullName, b.FullName, StringComparison.OrdinalIgnoreCase)).ToList();
                    foreach (var reference in distinctReferences)
                    {
                        var referencedAssembly = Assembly.Load(reference.FullName).CodeBase.Substring("file:///".Length);
                        compilerParameters.ReferencedAssemblies.Add(referencedAssembly);
                    }
                    var compilerResults = CodeProvider.CompileAssemblyFromDom(compilerParameters, result.GeneratedCode);
                    if (compilerResults.Errors.HasErrors)
                    {
                        var errorText = new StringBuilder();
                        foreach (var compilerError in compilerResults.Errors)
                        {
                            errorText.AppendLine(compilerError.ToString());
                        }
                        throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture,
                            "The following errors were detected attempting to compile the partial view {0}: \n{1}",
                            virtualPath, errorText));
                    }
                    var typeName = string.Format(CultureInfo.InvariantCulture, "{0}.{1}",
                        host.DefaultNamespace, host.DefaultClassName);
                    var type = compilerResults.CompiledAssembly.GetType(typeName);
                    return type;

                }
            }
        }

This method will give you a Type which you can then use reflection with to arrive at the Execute method, which you can then invoke.  The trick is going to be changing the meaning of WriteLiteral so that it outputs to an arbitrary stream, like a cs file.
