title: T4 code generation during build, custom assembly reference
body: <p>I have a T4 template that processes several .tt files in my project.  I also have some custom classes I've defined to help with the code transformation process.</p>
  
  <pre><code>&lt;#@ template language="C#"  hostspecific="True" debug="True" #&gt;
  &lt;#@ output extension="cs" #&gt;
  &lt;#@ assembly name="System.Core.dll" #&gt;
  &lt;#@ assembly name="$(TargetDir)\MyDependency.dll" #&gt; 
  </code></pre>
  
  <p>This works in Visual Studio, I have a VS Macro which defines $(TargetDir) correctly.</p>
  
  <p>Now, I want to perform the code generation process during my build process.  I added:</p>
  
  <pre><code>&lt;TransformOnBuild&gt;true&lt;/TransformOnBuild&gt;
  &lt;OverwriteReadOnlyOutputFiles&gt;true&lt;/OverwriteReadOnlyOutputFiles&gt;
  &lt;IncludeDslT4Settings&gt;true&lt;/IncludeDslT4Settings&gt; &lt;ItemGroup&gt;
  &lt;T4ReferencePath Include="$(OutputPath)" /&gt;
  &lt;/ItemGroup&gt;
  &lt;Import Project="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\TextTemplating\v10.0\Microsoft.TextTemplating.targets" /&gt; 
  </code></pre>
  
  <p>My build runs, but I get:</p>
  
  <blockquote>
    <p>C:\Program Files
    (x86)\MSBuild\Microsoft\VisualStudio\TextTemplating\v10.0\Microsoft.TextTemplating.targets
    (407): The host threw an exception while trying to resolve the
    assembly reference '$(TargetDir)\MyDependency.dll'. The transformation
    will not be run. The following Exception was thrown:
    System.IO.FileLoadException: The given assembly name or codebase was
    invalid. (Exception from HRESULT: 0x80131047)    at
    System.Reflection.AssemblyName.nInit(RuntimeAssembly&amp; assembly,
    Boolean forIntrospection, Boolean raiseResolveEvent)    at
    System.Reflection.AssemblyName.nInit()    at
    Microsoft.VisualStudio.TextTemplating.GlobalAssemblyCacheHelper.GetLocation(String
    strongName)    at
    Microsoft.VisualStudio.TextTemplating.Sdk.Host.GenericTextTemplatingHost.ResolveAssemblyReference(String
    assemblyReference)    at
    Microsoft.VisualStudio.TextTemplating.Engine.ResolveAssemblyReferences(ITextTemplatingEngineHost
    host, TemplateProcessingSession session). Line=-1, Column=-1</p>
  </blockquote>
  
  <p>Obviously it won't resolve <code>$(TargetDir)</code> in Team build context.</p>
  
  <p>I tried adding TargetDir to my build configuration's property group, to no avail.  This value doens't pass through to the context of the T4 Code Generator.</p>
  
  <p>I don't want to use an environment variable.</p>
  
  <p>How can I set <code>$(TargetDir)</code> correctly in Team Build context?</p>