Add variables to your custom `dotnet new` template
Previously, I covered creating your first custom dotnet new template. Now, let’s work on customizing the content our template generates based on inputs provided via the command line. I’ll be working from the same custom template from that post, which is just a dotnet new console output with its own .template.config setup. If you want a starter template project to get you going, use the template from the 1-custom-template folder from the Git repo from that blog post. This is the second in a collection of posts about creating custom templates for the dotnet new system. Your first input parameter When you are generating content from a template, your first parameter for controlling things is built in to the SDK. There are two variables used to decide where to put the generated content: –output and –name. If you provide a path via –output “some/path”, the content will be generated in that location. If, in your template’s template.json file, you set “preferNameDirectory”: true, you can set the same path via –name “some/path”. (If you have the preferNameDirectory variable set to true and provide both an output and name variable, it will use the output value.) Without either command-line parameter, the new… Continue reading