title: T4 Include .cs is looking for ITextTemplatingEngineHost
body: <p>My data access project is C# .Net 4.5. I've added a ttinclude file, based off of this post: <a href="http://erraticdev.blogspot.com/2011/01/generate-enum-of-database-lookup-table.html" rel="nofollow">http://erraticdev.blogspot.com/2011/01/generate-enum-of-database-lookup-table.html</a></p>
  
  <p>My file (EnumTypes.ttinclude) looks like this:</p>
  
  <pre><code>&lt;#@ template debug="true" hostSpecific="true" #&gt;
  &lt;#@ output extension=".generated.cs" #&gt;
  &lt;#@ Assembly Name="EnvDTE" #&gt;
  &lt;#@ Assembly Name="System.Data" #&gt;
  &lt;#@ import namespace="EnvDTE" #&gt;
  &lt;#@ import namespace="System.Data" #&gt;
  &lt;#@ import namespace="System.Data.SqlClient" #&gt;
  &lt;#@ import namespace="System.IO" #&gt;
  &lt;#@ import namespace="System.Text.RegularExpressions" #&gt;
  &lt;# 
      string tableName = Path.GetFileNameWithoutExtension(Host.TemplateFile);
      string path = Path.GetDirectoryName(Host.TemplateFile);
      string columnId = tableName + "ID";
      string columnName = tableName + "Name";
      string columnDescription = "Description";
      string connectionString = "Data Source=192.168.1.16;Initial Catalog=Mkp;Persist Security Info=True;User ID=sa;Password=1g1gl0b@l; MultipleActiveResultSets=true;Min Pool Size=20; Max Pool Size=200;Pooling=true;Connection Timeout=30";
  
      // Get containing project
      IServiceProvider serviceProvider = (IServiceProvider)Host;
      DTE dte = (DTE)serviceProvider.GetService(typeof(DTE));
      Project project = dte.Solution.FindProjectItem(Host.TemplateFile).ContainingProject;
  #&gt;
  using System;
  using System.CodeDom.Compiler;
      ...
  </code></pre>
  
  <p>My IdentifierType.tt file which is supposed to use that looks like this:</p>
  
  <pre><code>&lt;#@ template language="C#" #&gt;
  &lt;#@ assembly name="System.Core" #&gt;
  &lt;#@ import namespace="System.Linq" #&gt;
  &lt;#@ import namespace="System.Text" #&gt;
  &lt;#@ import namespace="System.Collections.Generic" #&gt;
  &lt;#@ include file=".\EnumTypes.ttinclude" #&gt;
  </code></pre>
  
  <p>The generated EnumTypes.cs file has these lines:</p>
  
  <pre><code>private global::Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost hostValue;
  public virtual global::Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost Host
  {
      //...
  }
  </code></pre>
  
  <p>However, the IDE cannot find ITextTemplatingEngineHost. When I try to add a reference to 'Microsoft.VisualStudio.TextTemplating.Interfaces' I can't find it on my machine. Is there a NuGet package I need?</p>
  
  <p>I'm trying to read up on T4s so I can understand what's happening, but any help would be great.</p>
  
  <p>Edit:
  I was able to fix the .cs error for ITextTemplatingEngineHost by browsing to 'C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.VisualStudio.TextTemplating.Interfaces.10.0\v4.0_10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll\' on my machine.</p>
  
  <p>I now get the error: 'The name 'Host' does not exist in the current context'</p>
  
  <p>ANSWERED:
  I had the wrong Custom Tool. I needed set the Custom Tool on the File Properties to 'TextTemplatingFileGenerator'.</p>