可以在 t4 模板中导入哪些库有任何限制吗? [英] Are there any limitations on what libraries can be imported in a t4 template?

查看:40
本文介绍了可以在 t4 模板中导入哪些库有任何限制吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在尝试学习使用 T4 模板.我希望使用 System.Data.Entity.Design.PluralizationServices 库,以便更好地将模板中的某些实体模型名称复数化,但在实现此目标时遇到了一些问题.

We're trying to learn to use T4 Templates. I have a desire to use the System.Data.Entity.Design.PluralizationServices library in order to better pluralize some Entity Model names within my template, but I've come across some issues in the achievement of this goal.

  1. 运行代码以生成输出文本.我认为这是可能的,但如果它不起作用,那么就没有必要再进一步了.(我可以调用 Date.Now.ToString() 并得到预期的结果.我还没有尝试过更复杂的东西)
  2. 我在 Silverlight 应用程序中,因此无法在需要生成的 .cs 文件的位置添加对 PluralizationServices 库项目的引用.我打算只将 .tt 文件移动到非 SL 应用程序,使用命名空间并将生成的文件移动到正确的空间.还没到那一步,所以我不知道会有多少麻烦,但看起来应该不会太难.

我目前的问题是,当我导入库的命名空间时,我得到一个ErrorGeneratingOutput",但我还没有能够继续过去.

My current problem is that when I import the namespace of the library, I get an "ErrorGeneratingOutput" and I haven't been able to move on past that yet.

我很难找到有关 import 命令如何工作的信息,所以我认为这很明显.但与此同时,这个不起作用,所以我想知道它是否可能是标准的例外.

I am having a hard time finding information about how the import command works, so I assume that it's just obvious. At the same time though, this one doesn't work so I wonder if it might be an exception to the standard.

<#@import namespace="System.Data.Entity.Design.PluralizationServices" #> 

我不知道为什么添加这一行(并且只有这一行)会导致一切中断.我什至还没有开始尝试使用它!我应该知道或阅读有关 T4 中图书馆的某些内容吗?谢谢!

I have no idea why adding this line (and only this line) causes everything to break. I haven't even started to try to use it yet! Is there something somewhere about libraries in T4 that I should know or read? Thanks!

推荐答案

这里有一个 描述 导入指令的工作原理.不知道在您的环境中转换模板时 T4 报告的实际错误,我只能猜测您没有添加 assembly 指令以引用 System.Data.Entity.Design 程序集.如果这样不行,看看visual studio的Error List中T4报的错误,应该比ErrorGeneratingOutput"更有帮助.

Here a description of how the import directive works. Without knowing the actual error T4 reports when transofrming the template in your environment, I can only guess that you didn't add an assembly directive to reference the System.Data.Entity.Design assembly. If this doesn't work, look at the errors reported by T4 in the Error List of visual studio, which should be more helpful than "ErrorGeneratingOutput".

这篇关于可以在 t4 模板中导入哪些库有任何限制吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆