Create and install custom project templates
JetBrains Rider supports the template system used by the .NET CLI command dotnet new, which allows you to use project templates from the .NET template catalog as well as custom templates that you can create on your own.
There are two ways to install new project templates.
You can run
dotnet new install <template-package>in the command line, where<template-package>is a NuGet package ID, a path to a .nupkg file, or a path to a template folder. This requires the .NET SDK.In the New Project/New Solution dialog, click Install Templates… below the template list. If you have already added a custom template source, click Manage Templates… instead. In the dialog that opens, click Install Template… and select a template folder containing .template.config or a .nupkg file.
When the template path appears in the list, click Close. JetBrains Rider reloads the available templates.
Create custom project template
Create a project with the required structure. You can take any project as a starting point or create a new one using any of the existing templates.
The following example uses a console project targeting .NET 10 with one source file.
ConsoleAppAsyncMain ├── bin ├── obj ├── MyProject.csproj ├── Program.csMyProject.csproj sets
TargetFrameworktonet10.0. Program.cs contains anasync Mainmethod as the application entry point:using System; using System.Threading.Tasks; namespace MyProject { class Program { static async Task Main(string[] args) { Console.WriteLine("Hello World!"); } } }Copy the project folder to a location from which you will use it as a template.
Remove bin, obj, and any other directories and files that are not related to the source code of the template.
In the copied project directory (which is now the template directory), add a folder named .template.config and a file named template.json inside it.
Now the template structure should look as follows:
MyTemplates ├── ConsoleAppAsyncMain ├── .template.config ├── template.json ├── MyProject.csproj ├── Program.csSpecify template properties in the template descriptor template.json.
The following descriptor defines the template, its target framework choices, and a greeting parameter. Use target frameworks supported by the project and the installed .NET SDK. For more information, refer to Custom templates for dotnet new.
{ "author": "Your Name", "name": "Async Main Console Application", "description": "A project for creating a command-line application that can run on .NET on Windows, Linux and macOS, and has an async Main method.", "identity": "YourName.ConsoleApp.1.0", "shortName": "consoleasync", "tags": { "language": "C#", "type": "project" }, "sourceName": "MyProject", "symbols": { "Framework": { "type": "parameter", "description": "The target framework for the project.", "datatype": "choice", "choices": [ { "choice": "net8.0" }, { "choice": "net10.0" } ], "defaultValue": "net10.0", "replaces": "net10.0" }, "Greeting": { "type": "parameter", "datatype": "string", "description": "The message printed by the application.", "defaultValue": "Hello World!", "replaces": "Hello World!" } } }Set
sourceNameto the name used in the original project:MyProjectin this example.When you create a project from this template, the template engine replaces this value in file names and file contents with the new project name.
In this example, the new name replaces the project file name and the namespace in Program.cs. The
replacesproperties make the template engine substitute the selected framework and greeting in the project files.Install the template in the New Project/New Solution dialog. Click Install Templates… or Manage Templates…, then click Install Template… and select the ConsoleAppAsyncMain folder containing .template.config.
When the template path appears in the list, click Close to reload the templates.
Select the installed template under Custom Templates in the list on the left. Specify the project options and click Create.
Customize a template for JetBrains Rider
To customize how a .NET project template appears in JetBrains Rider, add rider.host.json beside template.json in the .template.config folder. These overrides let you provide different labels and defaults for JetBrains Rider without changing the template configuration for other hosts.
JetBrains Rider also accepts Rider.host.json and uses it in preference to rider.host.json if both files exist. It does not use ide.host.json or dotnetcli.host.json as fallbacks. The supported properties follow the ide.host.json schema, with the limitations described below.
For example, the following host file customizes the Greeting parameter from the template above. It keeps the option visible, changes its label and tooltip, and sets a default greeting for projects created in JetBrains Rider:
The following properties are supported:
Property | Behavior |
|---|---|
| At the root level, override the template name and description. In a |
| An array of option overrides. Each entry identifies an existing option by |
| Set |
| Override the default of a visible option. Use a string, including for Boolean and numeric values: for example, |
| An array within a choice option entry. Match each existing choice by |
| Set to |
To reload an installed template after changing its host file, open Manage Templates… in the New Project/New Solution dialog and click Close.