I have a T4 template for a class set up with TextTemplatingFileGenerator Custom Tool in Visual Studio:
<#@ template language=\"C#v3.5\" hostspecific=\"Tru
Damien Guard includes some code in a blog posting which retrieves the Custom Tool Namespace for a given file:
public override String GetCustomToolNamespace(string fileName) { return dte.Solution.FindProjectItem(fileName).Properties.Item("CustomToolNamespace").Value.ToString(); }