Use boilerplate solution with “dotnet new” and stay DRY

  • support any programming language
  • offer a simple way to create new custom templates and distribute them
  • installation on local machine should be very easy
  • support of templates customization during creation

dotnet new

There is a tool which is developed by .NET community which supports almost everything from my list above. It’s dotnet new. If you’re .NET developer, you already have this tool installed since it’s a part of .NET Core SDK. If you’re not, you may be interested in having a glance at it, because as I noticed it can be used with any languages since it operates with files. If you’re a front-end developer you might have experience with React boilerplate tools or similar. In contrast dotnet new doesn’t stick you to .NET framework. You can use it for, basically, creating a folder with predefined files, structure and replace text in files, execute post actions. It shouldn’t be only C#. And you can create your templates almost “in the blink of an eye”.

The easiest way

The easiest way to get it to work for you is not the best way. But it’s very quick and you can start sharing templates in your team. You need to create a Git repository with a template solution. This solution should be correct according to the programming language of your choice. For example, for C# you should be able to compile it. Now you need to add a definition of the template:

"$schema": "",
"author": "Me",
"classifications": [
"identity": "shortNameOfTemplate",
"name": "Description of the template",
"shortName": "shortNameOfTemplate",
"tags": {
"language": "C#",
"type": "project"
"symbols": {
"projectName": {
"type": "parameter",
"datatype": "text",
"replaces": "TemplateAppSample",
"defaultValue": "TemplateAppSample"
dotnet new -i <absoluteOrRelativePath>
dotnet new shortNameOfTemplate

The advanced way

You can create a template pack and distribute it via NuGet package. The package could be deployed to your private NuGet server. The installation in such a case would be as easy as follows:

dotnet new -i MyTemplatePack::1.0.0 --nuget-source  http://MyPrivateNuGetServer/v3/index.json

Browsing, Updating and Uninstalling of Templates

You can check installed templates by running the command dotnet new --list . It will show you the following output:

dotnet new -u <absolutePath>
dotnet new -u MyTemplatePack




Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store