传统上,Visual Studio 中曾经有脚手架来加速添加 Controller 、区域、 View 等。 在我安装 ASP.NET Core 后,我注意到所有这些都消失了,这太可怕了(尤其是当你想添加一个新的区域,手动完成这项工作会导致颈部疼痛)。
有什么办法可以把它们带回来吗?为什么微软团队会做出如此糟糕的决定?
最佳答案
Is there any possible way to bring them back?
您需要添加必要的包:
Microsoft.VisualStudio.Web.CodeGeneration.Tools
Microsoft.VisualStudio.Web.CodeGenerators.Mvc
这是一个示例 project.json 文件:
{
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.0.1",
"type": "platform"
},
"Microsoft.AspNetCore.Mvc": "1.0.1",
"Microsoft.AspNetCore.Hosting": "1.0.0",
"Microsoft.AspNetCore.StaticFiles": "1.0.0",
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"type": "build"
},
"Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
"version": "1.0.0-preview2-final",
"type": "build"
}
},
"tools": {
"Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
"version": "1.0.0-preview2-final",
"imports": [
"portable-net45+win8"
]
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": [
"dotnet5.6",
"portable-net45+win8"
]
}
}
}
添加这些包后,您将可以访问脚手架。
作为引用,上面的屏幕截图来自 Visual Studio 2015 Update 3,具有以下相关扩展:
关于visual-studio-2015 - 缺少脚手架 ASP.Net Core,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39938246/