templating icon indicating copy to clipboard operation
templating copied to clipboard

Add optional argument to dotnet new for adding .gitignore

Open isaacrlevin opened this issue 3 years ago • 9 comments

Is your feature request related to a problem? Please describe.

Based off of Twitter thread for folks https://twitter.com/isaacrlevin/status/1571908208675147776

Describe the solution you'd like

Adding a new argument to dotnet new that will allow adding a .gitignore to the output of the command. For instance

dotnet new web --add-git

isaacrlevin avatar Sep 19 '22 19:09 isaacrlevin

First step would be to identify the templates that should have this option. Only some of them are in this repo. You can check the README on the dotnet/templating repo for a more up-to-date list of repos that own specific templates - I try to keep that up to date. Then, for each project template that should have this option, you'd add a new symbol to the template.json - note that there are different templates for each supported language, so you'd need to replicate that symbol.

Once you have a symbol defined, you'd add a postAction that has a condition that checks the symbol you defined earlier. I'd suggest looking at the run script postAction. Once you've made the changes, you can test by running dotnet new install path/to/template/folder to install the templates in that folder, invoke them, then uninstall with dotnet new uninstall path/to/template/folder.

baronfel avatar Sep 19 '22 19:09 baronfel

Got it, so there isn't a universal template that all the other templates inherit from? I was thinking at the same level the output argument, but you are saying it needs to be done at every template.

isaacrlevin avatar Sep 19 '22 19:09 isaacrlevin

Correct - there's no inheritance here. Each template is an island.

baronfel avatar Sep 19 '22 20:09 baronfel

Got it. So this change will need to be in a few different repos than. I will take a look

isaacrlevin avatar Sep 19 '22 20:09 isaacrlevin

this is very much related to https://github.com/dotnet/templating/issues/3208 and https://github.com/dotnet/templating/issues/2771.

vlada-shubina avatar Sep 21 '22 14:09 vlada-shubina

@vlada-shubina is there work being done in this space? I would hate to start the process of updating every template if there is a new process coming at some point.

isaacrlevin avatar Sep 21 '22 20:09 isaacrlevin

No, unfortunately there is no definite timeline for those features at the moment.

vlada-shubina avatar Sep 22 '22 07:09 vlada-shubina

@baronfel when I get to a point to test the templates, I assume I need to build them into a a nupack file from the repo the templates are in (for instance the aspnet repo)? Than build a new version of dotnet new than run the command you provided? The docs aren't super clear

isaacrlevin avatar Sep 26 '22 21:09 isaacrlevin

We decided it falls in scope of https://github.com/dotnet/templating/issues/3208 or https://github.com/dotnet/templating/issues/2771, but there is no definite timeline on that yet.

vlada-shubina avatar Oct 03 '22 07:10 vlada-shubina