From http://blog.stevensanderson.com/2011/04/07/mvcscaffolding-creating-custom-scaffolders/ :
In the Visual Studio Package Manager console, run the following command:
Scaffold CustomScaffolder ClassName
This adds a CodeTemplates folder to the project containing the files for the new core.
As you can see, we have two files:
- PowerShell script (.ps1) where we can put arbitrary logic to decide which templates will be rendered and where the result will be displayed. From default, it displays the T4 template and uses the output to create a new file called ExampleOutput in the root directory of your project.
T4 template (.t4) , i.e. what the default .ps1 file does. By default, a simple C # / VB class is created (depending on your project type). If you want this to work, you can run the custom skiffolder right away:
Scaffold ClassName
This will create a new file of the ExampleOutput.cs class in the root of your project folder. It is really simple to show you how it works. We donβt really want this, so we are not starting a new scaffolder yet, or if you have already done so, delete ExampleOutput.cs
source share