且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何添加在Visual Studio 2013中使用脚手架脚手架新?

更新时间:2023-02-25 17:33:56

在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. 在形式创建一个文件有< TEMPLATENAME方式><郎> .t4 其中< TEMPLATENAME> 是要在MVC视图棚架的下拉列表和&LT展现出来什么;郎> 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.

看看这篇博客文章,通过如何编写自定义的棚架散步:为Visual Studio 创建自定义棚架

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