问题描述
我的工作我的第一个T4代码生成工具,一些存储过程助手的代码添加到我的项目。我创建自定义的类型(如的StoredProcedure
和 StoredProcedureParameter
来帮助我的代码生成和包括装配和命名空间#@模板调试=假hostspecific =假LANGUAGE =VB#;
I'm working on my first T4 code generation tool to add some Stored Procedure helper code to my project. I've created custom types (e.g. StoredProcedure
and StoredProcedureParameter
to help with my code generation and have included the assembly and namespace references in my code:
<#@ template debug="false" hostspecific="false" language="VB" #>
<#@ output extension=".generated.vb" #>
<#@ assembly name="$(TargetPath)" #>
<#@ import namespace="StoredProcCodeGenerator" #>
这让我可以在我的T4模板中使用我的自定义类型代码。然而,由于在同一个项目的T4模板代码存在我的自定义类型,我不能一次我无需重新启动Visual Studio中运行模板代码重新编译我的项目,这是不是很有趣。
This allows me to use my custom types in my T4 template code. However, because my custom types exist in the same project as the T4 template code, I can't recompile my project once I run the template code without restarting Visual Studio. This isn't very much fun.
我读了伟大的文章通过使用T4工具箱解决了这个确切的问题,但它不工作。无论我实施 VolatileAssembly
指令错误或T4工具箱根本就没有得到安装。我不知道该工具箱中得到了正确安装(我使用VS 2010在Win XP)。
I read a great article that addresses this exact issue by using the T4 Toolbox, but it's not working. Either I'm implementing the VolatileAssembly
directive wrong or the T4 toolbox simply didn't get installed. I'm not sure that the toolbox got installed correctly (I'm using VS 2010 on Win XP).
有什么办法,我也许能解决这个问题问题?
What are some ways that I might be able to fix this problem?
推荐答案
您需要删除以前的组装
引用和然后的添加 VolatileAssembly
引用。如果不删除定期组装
引用第一,你会得到一个错误,当你添加 VolatileAssembly 已添加。code>引用
You need to remove the previous assembly
reference and then add the VolatileAssembly
reference. If you don't remove the regular assembly
reference first, you'll get an error that it has already been added when you add the VolatileAssembly
reference.
<#@ template debug="false" hostspecific="false" language="VB" #>
<#@ output extension=".generated.vb" #>
<#@ VolatileAssembly processor="T4Toolbox.VolatileAssemblyProcessor"
name="$(TargetPath)" #>
<#@ import namespace="StoredProcCodeGenerator" #>
现在你可以继续建立自己的项目,并在你的T4模板使用在该项目中定义的类型。
Now you can continue to build your project and use types defined in that project within your T4 templates.
这篇关于使用类型T4模板存在于同一个项目作为模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!