如何添加在Visual Studio 2013中使用脚手架脚手架新? [英] How to add new Scaffold used in Visual Studio 2013 Scaffolding?

查看:1599
本文介绍了如何添加在Visual Studio 2013中使用脚手架脚手架新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法添加一个新的支架或覆盖新的Visual Studio中使用的脚手架功能2013脚手架?

Is there a way to add a new Scaffold or override the Scaffolding functionality used in the new Visual Studio 2013 Scaffolding?

我可以在互联网上找到的唯一文档是如何覆盖使用codeTemplates文件夹中的T4模板。我想一个新的脚手架添加到列表中添加时...>新建项目脚手架......它看起来像在Visual Studio 2013这已被轧成库(Microsoft.AspNet.Scaffolding.Mvc.5.0.dll)和在GAC或作为VS扩展注册。

The only documentation I can find on the internet is how to override the T4 templates using the CodeTemplates folder. I want to add a new Scaffold to the list when Add... > New Scaffold Item... It looks like in Visual Studio 2013 this has been rolled into a library (Microsoft.AspNet.Scaffolding.Mvc.5.0.dll) and registered in the GAC or as a VS Extension.

<一个href=\"http://weblogs.asp.net/imranbaloch/archive/2013/09/15/customizing-the-asp-net-mvc-5-web-api-2-scaffolding-templates.aspx?CommentPosted=true#commentmessage\">http://weblogs.asp.net/imranbaloch/archive/2013/09/15/customizing-the-asp-net-mvc-5-web-api-2-scaffolding-templates.aspx?CommentPosted=true#commentmessage

我要重写调用T4模板,所以我可以创建不同的文件和增强功能的机制。我的具体需要的是,我想脚手架老CreateOrEdit.cshtml和新的DetailsOrDelete.chtml部分景色。我也想脚手架一个工具,需要一个资源文件并生成本地化资源文件中的另一种语言。

I want to override the mechanism that calls the T4 templates so I can create different files and enhanced the functionality. My specific need is that I want to scaffold the old CreateOrEdit.cshtml and a new DetailsOrDelete.chtml partial views. I would also like to Scaffold a tool that takes a resource file and generates the localized resource file in another language.

推荐答案

在Visual Studio 2013 RTM有一个添加完全自定义的架子工的支持。你只能做以下自定义:

In Visual Studio 2013 RTM there is no support for adding completely custom scaffolders. You can only do the following customizations:


  1. 您可以编辑或覆盖控制器,区域,视图等现有的T4模板。

  2. 您可以添加自定义查看架子工,将在现有的MVC视图棚架现身

在Visual Studio团队正在重新启用自定义棚架支持在Visual Studio的更新版本。

The Visual Studio team is working on re-enabling custom scaffolder support in a future update of Visual Studio.

要添加的今天自定义视图棚架:

To add a custom view scaffolder today:


  1. 在VS2013创建任何ASP.NET项目

  2. 添加文件夹,名为 codeTemplates

  3. 创建一个子文件夹中有名为无论是 MvcView MvcViewWithoutModel 根据您的自定义视图模板是否是强类型的视图

  4. 在形式创建一个文件有&LT; TEMPLATENAME方式&gt;&LT;郎&GT; .t4 其中&LT; TEMPLATENAME&GT; 是要在MVC视图棚架的下拉列表和&LT展现出来什么;郎&GT; CS VB

  1. Create any ASP.NET project in VS2013
  2. Add a folder called CodeTemplates
  3. Create a sub-folder in there called either MvcView or MvcViewWithoutModel depending on whether your custom view template is a strongly-typed view
  4. Create a file there in the form of <templatename>.<lang>.t4 where the <templatename> is whatever you want to show up in the MVC View scaffolder's drop down list and <lang> is either cs or vb.

要开始,你可以从VS2013的默认​​列表复制任何现有的棚架和定制。您可以从这里得到内置架子工:

To get started you can copy any existing scaffolder from VS2013's default list and customize it. You can get the built-in scaffolders from here:

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Web\Mvc\Scaffolding\Templates\MvcView
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Extensions\Microsoft\Web\Mvc\Scaffolding\Templates\MvcViewWithoutModel

如果您使用相同的名称与现有棚架那么它将覆盖内置的棚架,从另一个名为棚架甚至当。例如,MVC控制器棚架将使用在你的项目中被覆盖的视图棚架。

If you use the same name as an existing scaffolder then it will override the built-in scaffolder, even when called from another scaffolder. For example, the MVC controller scaffolder will use an overridden view scaffolder that is in your project.

2014年4月22日更新

现在的Visual Studio 2013更新2可那previews,就可以写出完全自定义的脚手架。

Now that previews of Visual Studio 2013 Update 2 are available, it is possible to write completely custom scaffolders.

看看这篇博客文章,通过如何编写自定义的棚架散步:<一href=\"http://blogs.msdn.com/b/webdev/archive/2014/04/03/creating-a-custom-scaffolder-for-visual-studio.aspx\"相对=nofollow>为Visual Studio 创建自定义棚架

Check out this blog post that walks through how to write a custom scaffolder: Creating a Custom Scaffolder for Visual Studio

这篇关于如何添加在Visual Studio 2013中使用脚手架脚手架新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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