【问题标题】:Visual Studio variables not being transformed when generating code via TDS通过 TDS 生成代码时未转换 Visual Studio 变量
【发布时间】:2014-08-12 23:18:27
【问题描述】:

当在 .tt T4 模板中引用程序集时,我应该能够使用以下声明:

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

据我所知,SolutionDir 没有被转换,我收到一条错误消息(如下)

注意:HedgehogDevelopment.CodeGeneration.Extensions.dll 不能添加到 GAC 或 Visual Studio 程序集文件夹,因为 DLL 需要与项目一起传递。

我不知道TDS代码生成是如何执行的,所以我在这里问一下是否有人解决了类似的问题。

错误 | 10 |主机在尝试解决 装配参考 '$(SolutionDir)......\Build\lib\HedgehogDevelopment.CodeGeneration.Extensions.dll'。 转换将不会运行。

以下异常是 抛出:System.IO.FileLoadException:给定的程序集名称或 代码库无效。 (来自 HRESULT 的异常:0x80131047)在 System.Reflection.AssemblyName.nInit(RuntimeAssembly& 程序集, Boolean for Introspection, Boolean raiseResolveEvent) 在 System.Reflection.AssemblyName..ctor(字符串 assemblyName) 在 Microsoft.VisualStudio.TextTemplating.GlobalAssemblyCacheHelper.GetLocation(字符串 强名)在 Microsoft.VisualStudio.TextTemplating.VSHost.TextTemplatingService.ResolveAssemblyReference(字符串 装配参考)在 Microsoft.VisualStudio.TextTemplating.Engine.ResolveAssemblyReferences(ITextTemplatingEngineHost 主机,TemplateProcessingSession 会话)

【问题讨论】:

  • 什么是“TDS”?没听说过,标签wiki是空的。
  • @JohnSaunders Team Develpoment for Sitecore 非常适合 Sitecore 开发。
  • @jammykam:谢谢。我更新了标签 wiki。
  • 扩展方法现已移至 T4 文件中。这应该有助于解决您的原始问题。我更新了我的答案以反映这一点。

标签: sitecore t4 tds


【解决方案1】:

确保将HedgehogDevelopment.CodeGeneration.Extensions.dll 添加到 GAC 或 Visual Studio 程序集文件夹:

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

或者在指令中使用程序集的完整路径。

更新:

作为对此的更新,扩展方法 have now been moved 到 T4 文件中,因此您不再需要将 DLL 部署到 GAC 或 Visual Studio 文件夹。你可以找到updated files in the Github repo

【讨论】:

  • 我需要能够在不将 DLL 添加到 GAC 或 Visual Studio 文件夹的情况下运行它。换句话说,这需要与项目一起传递,不能在每台机器上“安装”。
  • 据我所知,它需要位于这些位置之一或完整路径中,因为它需要对 VS 可用。您是否能够将扩展项目添加到您的解决方案中,并按照链接帮助中的建议使用构建后步骤编译项目?
  • 我的猜测是 TDS 使用 TextTransform utility 而不是 VS 生成文件,因此它不知道 T4 模板是否属于项目或解决方案。我会向 Hedgehog Support 发送电子邮件,他们通常会很快回复。
  • 电子邮件已发送;会看到他们回来的。
  • @Dann 你从刺猬那里得到答案了吗?请随时更新,谢谢。
猜你喜欢
  • 2015-05-20
  • 1970-01-01
  • 2022-12-21
  • 1970-01-01
  • 2010-09-06
  • 2010-09-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多