I am building a plug-in in VS 2010 and I get stuck at the T4 generation. Right now I have implemented (like MSDN suggests) a custom T4 host to generate my T4 results and I use it in this way:
const string content = @"c:\Simple.tt";
var engine = new Engine();
var host = new MyTemplateHost();
var result = engine.ProcessTemplate(File.ReadAllText(content), host);
foreach (CompilerError error in host.Errors)
{
Console.WriteLine(error.ErrorText);
}
This works until I pass a parameter in the Template. As soon as I create a parameter in the .tt file, the Host freak out saying that it doesn't know how to resolve it. I saw that you can use the TemplateSession to do that but I didn't figure out how to pass it to my Host? Is there a better way of generating code from a .tt using C# and passing parameters at run-time? Maybe I am on the wrong path.