Visual Studio variables not being transformed when generating code via TDS


When referencing an assembly inside a .tt T4 template, I should be able to use the following declaration:

<#@ assembly name="$(SolutionDir)\..\..\Build\lib\HedgehogDevelopment.CodeGeneration.Extensions.dll" #>

From what I can see, the SolutionDir is not being transformed, and I get an error message (below)

Note: The HedgehogDevelopment.CodeGeneration.Extensions.dll cannot be added to the GAC or the Visual Studio assembly folder as the DLL needs to passed along with the project.

I don't know how the TDS code generation is executed, so I am asking here to see if someone has resolved something similar.

Error | 10 |The host threw an exception while trying to resolve the assembly reference '$(SolutionDir)......\Build\lib\HedgehogDevelopment.CodeGeneration.Extensions.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& assembly, Boolean forIntrospection, Boolean raiseResolveEvent) at System.Reflection.AssemblyName..ctor(String assemblyName) at Microsoft.VisualStudio.TextTemplating.GlobalAssemblyCacheHelper.GetLocation(String strongName) at Microsoft.VisualStudio.TextTemplating.VSHost.TextTemplatingService.ResolveAssemblyReference(String assemblyReference) at Microsoft.VisualStudio.TextTemplating.Engine.ResolveAssemblyReferences(ITextTemplatingEngineHost host, TemplateProcessingSession session)

asked on Stack Overflow Jan 29, 2014 by Dan • edited Jan 29, 2014 by Dan

1 Answer


Make sure you add HedgehogDevelopment.CodeGeneration.Extensions.dll to either the GAC or the Visual Studio Assemblies folder:

Or use the full path to the assembly in your directive.


As an update to this, the extension methods have now been moved into T4 files so you no longer need to deploy the DLL to the GAC or Visual Studio folder. You can find the updated files in the Github repo.

answered on Stack Overflow Jan 29, 2014 by jammykam • edited Aug 12, 2014 by jammykam

User contributions licensed under CC BY-SA 3.0