2

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)

3
  • What is "TDS"? Never heard of it, and the tag wiki is empty. Jan 29, 2014 at 18:19
  • 2
    @JohnSaunders Team Develpoment for Sitecore It's very specific for Sitecore development.
    – jammykam
    Jan 29, 2014 at 18:21
  • The extension methods have now been moved into T4 files. This should help with your original issue. I updated my answer to reflect that.
    – jammykam
    Aug 12, 2014 at 15:19

1 Answer 1

5

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

https://github.com/HedgehogDevelopment/tds-codegen/wiki/Using-Extension-Methods

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

UPDATE:

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.

6
  • I need to be able to run this without adding DLL to either the GAC or the visual studio folder. In other words, this needs to be passed along with the project and cannot be a "installed" per machine.
    – Dan
    Jan 29, 2014 at 18:25
  • As far as I know, it needs to be in one of those locations OR a full path since it needs to be available to VS. Are you able to add the extension project to your solution, and compile the project with the post build step as suggested in the linked help?
    – jammykam
    Jan 29, 2014 at 18:31
  • My guess is TDS generates the files using TextTransform utility rather than VS, so it doesn't know if a T4 template belongs to a project or solution. I would email Hedgehog Support, they are usually pretty quick to reply.
    – jammykam
    Jan 30, 2014 at 0:58
  • Email sent; will see what they come back with.
    – Dan
    Jan 30, 2014 at 11:21
  • @Dann Did you get an answer from Hedgehog? Please keep us updated when you do, thanks.
    – jammykam
    Feb 1, 2014 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.