简体   繁体   English

VS 2015中的T4模板

[英]T4 Template in VS 2015

How do I get T4 Template support in Visual Studio 2015 ? 如何在Visual Studio 2015中获得T4模板支持?
In VS 2015 the file property does not allow to specify the *tt file to be marked and allow to run from context menu. 在VS 2015中,file属性不允许指定要标记的* tt文件,并允许从上下文菜单运行。
I am using VS 2015 CTP6. 我正在使用VS 2015 CTP6。

Tried VS2015 Ultimate CTP6 and T4 support is in (as well as debugging T4 which is nice). 试过VS2015终极CTP6和T4支持(以及调试T4这很好)。 One specify TextTemplatingFileGenerator as Custom tool as before and when saving the .TT file it is executed. 像以前一样将TextTemplatingFileGenerator指定为自定义工具,并在保存.TT文件时将其执行。

There's a context menu called "Run Custom Tool" which seems to execute the .TT file as well. 有一个名为“运行自定义工具”的上下文菜单,它似乎也执行.TT文件。

As far as I can tell, the properties in the csproj have to be correct for the t4 template debug options to show up. 据我所知, csproj的属性必须正确才能显示t4模板调试选项。 This works for me in vs 2015 update 1 这适用于vs 2015更新1

There's two sections, the template and the output file. 有两个部分,模板和输出文件。

<Content Include="Entities\DataGenerator.tt">
  <Generator>TextTemplatingFileGenerator</Generator>
  <LastGenOutput>DataGenerator.cs</LastGenOutput>
</Content>

<Compile Include="Entities\DataGenerator.cs">
  <AutoGen>True</AutoGen>
  <DesignTime>True</DesignTime>
  <DependentUpon>DataGenerator.tt</DependentUpon>
</Compile>

*Note that TextTemplatingFileGenerator is case sensitive. *请注意, TextTemplatingFileGenerator区分大小写。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM