I have a problem when I'm building my project using MsBuild. I forced to generate file from T4 Template before every build. I have line like this in my T4 Template file:
IServiceProvider hostServiceProvider = (IServiceProvider)this.Host;
I'm getting exception that i cannot cast type 'Microsoft.VisualStudio.TextTemplating.CommandLine.CommandLineHost' on type 'System.IServiceProvider'. When I right click my tt file and choose 'Run custom tool' it is working ok. What is wrong here? How can I make it work?