ASP.NET Core中的自定义支架模板 [英] Custom scaffold templates in ASP.NET Core

查看:140
本文介绍了ASP.NET Core中的自定义支架模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在,我弄清楚了如何在ASP.NET Core MVC中启用脚手架(请参阅

Now that I figured out how to enable scaffolding in ASP.NET Core MVC (see View scaffold templates in ASP.NET Core), I'd like to create custom template files for Views. I found one place that said the template files are located here:

C:\ Users \ {用户名} \.dnx \ packages \ Microsoft.Extensions.CodeGenerators.Mvc \ 1.0.0-rc1-final \ Templates \ ViewGenerator

C:\Users\{user name}\.dnx\packages\Microsoft.Extensions.CodeGenerators.Mvc\1.0.0-rc1-final\Templates\ViewGenerator

但是我在此处复制了一个现有文件,并且该复制的文件没有出现在添加视图"对话框的模板"下拉列表中.它们是否位于其他地方,或者我必须做些什么才能使添加到该文件夹​​中的文件出现?重新启动Visual Studio并没有这样做.

But I copied an existing file there and that copied file does not appear in the Template dropdown on the Add View dialog. Are they located elsewhere, or do I have to do something to get files added in that folder to appear? Restarting Visual Studio did not do that.

推荐答案

我正在使用Microsoft.VisualStudio.Web.CodeGeneration.Tools 1.0.0-preview2-final

I am using Microsoft.VisualStudio.Web.CodeGeneration.Tools 1.0.0-preview2-final

模板位于此处...

C:\ Users \ {用户名} \.nuget \ packages \ Microsoft.VisualStudio.Web.CodeGenerators.Mvc \ 1.0.0-preview2-final \ Templates

C:\Users\{username}\.nuget\packages\Microsoft.VisualStudio.Web.CodeGenerators.Mvc\1.0.0-preview2-final\Templates

将Templates文件夹复制到您的项目中,然后根据需要对其进行编辑.

Copy the Templates folder to your project and edit them as required.

这篇关于ASP.NET Core中的自定义支架模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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