ASP.NET 5 (VS 2015) 中的设计时 T4 模板 [英] Design-time T4 templates in ASP.NET 5 (VS 2015)

查看:19
本文介绍了ASP.NET 5 (VS 2015) 中的设计时 T4 模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法在 ASP.NET 5 (vNext) 项目中找到在 VS 2015 RTM 中制作 T4 模板的方法.

I can't seem to find a way to make T4 templates in VS 2015 RTM, in an ASP.NET 5 (vNext) project.

我什至为 Visual Studio 2015 安装了 T4 工具箱扩展名,但 tt 模板没有被转换.

I even installed the T4 toolbox for Visual Studio 2015 extension, but the tt templates are not transformed.

Custom Tool 属性没有出现在 tt 文件属性中,我也找不到'Run Custom Tool'命令.

The property Custom Tool doesn't appear in the tt file properties, neither can't I find the 'Run Custom Tool' command.

更新

我想要 T4 模板的原因,是引入了 config.json 文件,以及可插拔的配置系统,这是一个很棒的东西,但代价是没有设置属性强类型.
我已阅读 这个 文章解释了如何实现这一点,但仍然没有生成.因为我有一个相当复杂的配置结构,所以我想制作一个 T4 模板来生成一个 AppSettings 文件.显然也欢迎任何关于这方面的想法.

The reason I want the T4 templates, is the introduction of the config.json file, and the pluggable configuration system, which is an awesome thing, but with the price of not having the setting properties strongly-typed.
I've read this article that explains how to achive this, but there is still no generation. Since I have a pretty complex configuration structure, I thought about making a T4 template that will generate an AppSettings file. Any ideas on that are obviously welcome too.

推荐答案

ASP.Net 5 (vnext) 项目是一个全新的动物,在技术上仍处于测试阶段,它不是 计划 RC 到 2015 年 11 月.此外,它还试图完全跨平台,因此团队最初倾向于使用 razor 模板而不是 T4 来搭建脚手架.他们根本没有计划支持 T4(或任何单个文件生成器),直到社区发出 呐喊 让他们改变了主意.根据该线程,他们将支持它,但没有给出日期.他们似乎确实取得了进展,早在一月份,当我测试我的 T4 扩展程序时,我遇到了项目问题文件(现在为 json 格式)不支持自定义属性,但截至 2015 年 7 月 20 日发布,它现在似乎可以工作了.在 Visual Studio 2015 中运行 T4 的引擎仍然存在,因此如果您喜欢其他项目类型,可以使用它.您可以创建一个控制台应用程序并让它存储 T4 文件,但在 vnext 项目中生成它们.如果您想要更简洁的解决方案,您还可以尝试我的扩展程序 T4 Awesome,它为您提供了一种组织和通过右键菜单调用您的模板.

The ASP.Net 5 (vnext) project is a completely new animal and technically still in beta, its not scheduled for RC til November 2015. Also it's attempting to be completely cross platform so initially the team favored using razor templates instead of T4 for scaffolding. They had no plans to support T4 (or any single file generators) at all until an out cry from the community made them change their mind. According to that thread they will support it but have given no dates. They do seem to have made progress, back in January when I was testing my T4 extension I had issues with the project file(now in json format) not supporting custom properties but as of the release on 7/20/2015 it seems to work now. The engine for running T4 inside of visual studio 2015 is still there so you can use it if you like from other project types. You can create a console app and have it store the T4 files but generate them in the vnext project. If you want a cleaner solution you can also try out my extension T4 Awesome, it gives you a way to organize and call your templates via right click menus.

这篇关于ASP.NET 5 (VS 2015) 中的设计时 T4 模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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