I'm using the T4 TextTemplating service from a VSPackage:
var t4 = this.GetService(typeof(STextTemplating)) as ITextTemplating;
Normally if a template is referencing types in an external assembly you can use the assembly
directive. However, I don't know the assembly until runtime, so is there anyway of adding assembly references to the T4 engine programmatically?