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)

Dan
  • 12,808
  • 7
  • 45
  • 54
  • What is "TDS"? Never heard of it, and the tag wiki is empty. – John Saunders Jan 29 '14 at 18:19
  • 2
    @JohnSaunders [Team Develpoment for Sitecore](http://www.hhogdev.com/products/team-development-for-sitecore/overview.aspx) It's very specific for Sitecore development. – jammykam Jan 29 '14 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 '14 at 15:19

1 Answers1

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.

jammykam
  • 16,940
  • 2
  • 36
  • 71
  • 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 '14 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 '14 at 18:31
  • My guess is TDS generates the files using [TextTransform utility](http://msdn.microsoft.com/en-us/library/bb126245.aspx) 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 '14 at 00:58
  • Email sent; will see what they come back with. – Dan Jan 30 '14 at 11:21
  • @Dann Did you get an answer from Hedgehog? Please keep us updated when you do, thanks. – jammykam Feb 01 '14 at 16:34
  • Yes. It is run via the Hedgehog Binaries and so no VS variables are provided to the transform. This also means there are no build targets associated. From a little of my own research, it appears that you can use environment variables e.g. %USERPROFILE%. I will see if I can rig up a solution that way. – Dan Feb 03 '14 at 09:27