dotnet / templating

This repo contains the Template Engine which is used by dotnet new
https://docs.microsoft.com/dotnet/
MIT License
1.59k stars 364 forks source link

Developers have modern interactive `dotnet new` experiences #6024

Open donJoseLuis opened 1 year ago

donJoseLuis commented 1 year ago

Background

Tasks


Originating issue: https://github.com/dotnet/templating/issues/3267 as proposed by @andrebaltieri The initial description:

Today we have a lot of templates and if you're starting on .NET is difficult to choose between them. Is also difficult to see what templates I can use... need to Google that.

If you're using Visual Studio, everything is more clear, the templates are organized and we have a GUI for that. But I think we have a lot of developers working through CLI, using VS Code.

The idea here is to have a global .NET command that show some selectable options on terminal, as Angular does when you start a new App.

For example dotnet new will show some questions to help me on creating my app.

dotnet new
  - Web application (ASP.NET/Blazor)
  - Mobile Application (MAUI)
  - Console Application
  ...

We can have more options after selecting the first one, and goes on. You got the idea. Please, let me know if this make sense.


Further examples: a. templates instantiation in CLI

> dotnet new console –interactive
> Optional prameter --use-program-main – Whether to generate …
   --use-program-main (leave empty for false): _

b. When failing to find command

> dotnet new comzole
> No templates found matching: 'comzole'.
> Did you want instantiate 'console' template by running 'dotnet new console'? Type [y]es to accept, [c]ancel to exit interactive mode, anything else to continue advices: _
> Do you want to search online for templates matching 'comzole'? Type [y]es to accept, [c]ancel to exit interactive mode, anything else to continue advices: _

c. During authoring a template

> dotnet new author --interactive
> Do you want to create a new template or from existing item/project? [N]ew, Existing [I]tem, Existing [P]roject: _
> Type the path to the project you want to turn into template: _
> Do you want to exclude common excludable items (build outputs, …, more info: github.com/dotnet/templating/doc/authoring/excludable-items): [y]es, [n]o: _
> Do you want to add some existing item templates to your project template?
> …

During search and list (again – possibly default with opt out):

> dotnet new search console
Searching for the templates...
Matches from template source: NuGet.org
…
You already a template installed exactly matching name 'console' and 3 additional approximate matches.
Do you want to:
 (a) instantiate the local template by running 'dotnet new console'? 
 (b) list the other matching local templates by running 'dotnet new list console'?
 (c) install the best online match by running 'dotnet new install Take.Blip.Client.Templates'?
 (d) exit the interactive mode

Type your option: _

Justification

  1. UX Improvement: interactive mode modernizes the template management dotnet new UX`.
  2. UX homogeneity: proof of concept for modernizing other dotnet tools interactivity.
  3. Aligns to .NET modernization OKRs.
vlada-shubina commented 1 year ago

Design: https://github.com/dotnet/templating/pull/6015

YuliiaKovalova commented 1 year ago

Prototype: https://github.com/dotnet/sdk/pull/30832