IT:AD:Transformations:T4:HowTo:Create a Transformation
Single File Transformation
If you write my.tt and stick an output directive on it, with an '.xx' extension attribute:
//This File is just a place holder. <#@ template language="C#" debug="false" hostspecific="true"#> <#@ include file="EF.Utility.CS.ttinclude"#> <#@ output extension=".xx"#>
it gets immediately transformed to an output file called my.xx in the same directory that contains:
//This File is just a place holder.
PS: I was curious: It appears that it will always generate the output file (I took of the whole output directive to see what would happen, but it just defaulted to outputting tt.cs -- with no content.
Taking that a bit further:
//This File is just a place holder. <#@ template language="C#" debug="false" hostspecific="true"#> <#@ include file="EF.Utility.CS.ttinclude"#> <#@ output extension=".cs"#>
<# // Get the project's default namespace IServiceProvider serviceProvider = (IServiceProvider)Host; DTE dte = (DTE)serviceProvider.GetService(typeof(DTE)); ProjectItem templateItem = dte.Solution.FindProjectItem(Host.TemplateFile); #>
namespace <#= templateItem.ContainingProject.Properties.Item("DefaultNamespace").Value #>.YourNameSpace
{
//...
}
Would produce a C# file with a namespace of your choosing.