weblar83
weblar83

Reputation: 731

Visual Studio 2017 ASP NET Core 2 Scaffolding Templates

Is it possible to add custom scaffolding templates to Visual Studio 2017 community for things like MVC Controllers and Views?

I've seen a number of tutorials which suggest adding custom templates to the following locations but nothing seems to work:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\Extensions\Microsoft\Web\Mvc\Scaffolding\Templates 
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\ItemTemplates\CSharp\Web\MVC 4\CodeTemplates
C:\Users\<user>\.nuget\packages\microsoft.visualstudio.web.codegenerators.mvc\2.0.4\Templates

For example, if I want to add a new Controller via the right-click menu, any custom templates added to the above locations just do not show. Likewise the View templates do not appear either.

Upvotes: 2

Views: 1490

Answers (1)

weblar83
weblar83

Reputation: 731

Ok, so the following steps work:

Copy the Templates folder from the following location to the root of the project directory:

C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.visualstudio.web.codegenerators.mvc\<version>

In VS2017, when adding a Controller or View, the selected scaffold is then brought in from the local Template directory residing within the project. These can be tweaked and changed as necessary.

It looks as though it is not possible to "add" to the scaffold list.

Upvotes: 3

Related Questions