VS 2015中的T4模板

5

我该如何在Visual Studio 2015中获取T4模板支持?
在VS 2015中,文件属性不允许指定*tt文件并允许从上下文菜单运行。
我正在使用VS 2015 CTP6。


这是CTP。也许他们还没有处理完?使用2013代替。 - Mitch Wheat
1
我似乎也无法在ASP.NET 5项目中显示它。(我正在运行CTP6) - William
Custom Tool 属性不存在。 - Shimmy Weitzhandler
据我所知,它仍然没有到达那里...WTF? - borrrden
算了,它在共享项目中无法工作...失败了。 - borrrden
我也遇到了这个愚蠢的问题。我只需要它来生成最简单的代码,但是.tt文件什么也做不了。该死。 - Richard Griffiths
2个回答

2

我尝试了VS2015 Ultimate CTP6版本,它支持T4(还能调试T4,这很不错)。像以前一样,我们可以将TextTemplatingFileGenerator指定为自定义工具,并在保存.TT文件时执行它。

此外,还有一个名为“运行自定义工具”的上下文菜单,似乎也可以执行.TT文件。


2
Custom Tool 属性不存在,也没有 *Run Custom Tool* 选项。 - Shimmy Weitzhandler

0
就我所知,csproj中的属性必须正确才能显示出t4模板调试选项。这在我使用的VS 2015更新1版本中有效。
有两个部分,一个是模板,另一个是输出文件。
<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>

*请注意,TextTemplatingFileGenerator是区分大小写的。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接