dotnet / dotnet/sdk

Feature request: Allow authors to customize the order of `dotnet new list` templates

Open
#54,289 0 comments 0 reactions 0 assignees View on GitHub
untriaged
Dominant language
C#
Stars
3.2k
Forks
1.3k
PR merge metrics
PR metrics pending

Description

### Summary

The order of templates in `dotnet new list` is hard-coded to alphabetical by display name in [`TemplateGroupDisplay.cs`](https://github.com/dotnet/sdk/blob/main/src/Cli/Microsoft.TemplateEngine.Cli/TabularOutput/TemplateGroupDisplay.cs#L248):

```csharp
.OrderBy(nameColumn, StringComparer.OrdinalIgnoreCase);
```

Template authors have no way to influence this order. Would you consider adding a `template.json` field that lets authors express their preferred display order, used as the primary sort key (falling back to alphabetical for templates that don't set it)?

### Motivating example

Imagine a template pack with four project templates that an author wants ordered from simplest to most advanced.

**Expect:**

1. Blank app
2. Navigation app
3. Tabbed app
4. Blank app with MVVM

**However**, alphabetical sort by `name` produces the following **actual** result:

1. Blank app
2. **Blank app with MVVM** ← jumps to slot 2 because of the second "B"
3. Navigation app
4. Tabbed app

I'd prefer not to work around this by adding sort prefixes to the `name` (e.g. `"1. Blank app"`), because those prefixes leak into `dotnet new list` output, short-name resolver hints, and IDE template pickers that reuse the same display name.

### See also:
There's a similar feature supported in Visual Studio templates: [sortorder-element-visual-studio-templates](https://learn.microsoft.com/en-us/visualstudio/extensibility/sortorder-element-visual-studio-templates?view=visualstudio)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.