Realize this is an older video but had a use case today for this. Spent the morning trying to create a multi-project template, the "old" way. That template export tool doesn't work well enough for solutions of any complexity, IMHO. Looked up the dotnet new template documentation, and found your video during that search. Microsoft should go a step further and mark the old way as obsolete for dotnet projects in their documentation. (Maybe I'll suggest it in a docs pull request). I now have a multiple project solution template, with references to infrastructure projects in shared folders, and loose files in solution folders. Made a template out of that solution after about 5 minutes of setup. Super fast, super awesome.
Thank you so much for this!! My Xamarin apps have a lot of boilerplate that I personally use, and this would save me SO MUCH time spinning up a new project!
For someone always starting projects, trying new things and learning new things, this is a life saver. I wasted no time and made my own. Now when I feel like I have found something I will use in every project, I put it in this template. Best video ever. QOL Game changer!🙃
Hi Nick. Any chance you could do an up to date version of this video? I have followed the video exactly and this no longer works :( I'm trying to create a template and failing miserably.
Wow, I'll be using that. 3 quick questions though, does it work with multiple projects in 1 template? What does it do with project names with spaces, because in some places you'd want to convert something like "My Project" to "My_Project", and in others you'd want to leave as-is. And how can you control the substitution on file names?
Yes, it's possible, when you create a template from the command line. But it doesn't work when you create a template from the wizard windows. Visual studio didn't implement it and I created a ticket for them with that, still waiting... :/
I might be crazy, but I did not figure out where did @Nick put link to documentation? I have tried to google for documentation but I am I am finding a proper documentation. Everything I have found is really short.
hey, i can't find any info about, so i am gonna try it here. When i have the .template.config at solution dir, and i create a new solution/project from the template. The new solution does not get a project added. 0. When i put the .template.config inside the template project. it works great. But i wanna try to get multiple projects to my template. But I cant figure it out. You got any advise?
Any reason why the template wouldn't show up in the Visual Studio Create a new project window? I can create a project from CLI but I'd like to be able to select my template in the UI. Is that not possible without Rider?
Hey @Nick Chapsas Thanks for this... what about multiple projects in a template, like say I want to create a whole SOLID, repository pattern solution as a template? Would be great to share a video for that.
Are you able to build the template project itself with all that parameterized entries, or do you need to generate a project form it to be able to test it?
man i would love to see if you can make a video which uses different types of text templating engine like fluid, mustache , etc different libs and benchmark them to get results for doing same thing to know which is the best templating engine with fast efficient ,etc etc
My template project has git history. When I install the template, I also seem to bring over the git history. The result is running dotnet new mytemplate -0 "mynewapp" creates a new project but it contains the git history of the template. Is there a way for me to ignore the .git folder when installing the template?
Thank you for this video it helps me a lot. I'm having trouble with "#if DEBUG" syntax that it seems to be removed when I create a new project from the template, any work around?
You can specify your own nuget source. That can be a local folder (but then sending updates to your team could be a problem) or your own nuget server hosted behind a VPN or something. This is what my team does. Then you and your team can add the nuget source in your IDE! Makes life so much easier. Otherwise, you'll probably need to make a git repo and your team can just pull the source and install locally as needed.
Thank you so much, I got tired from writing the same code again and again. this video really helped me a lot I have a question : Is there a way to add/ remove package? Eg: In the Swagger example, is there a way to remove the package from the project (csproj) when the enable swagger choice is false ?
@@jarrichvdv Couldn't agree more. When I tried creating an API project for test purposes, I saw a checkbox telling me it's for using minimal APIs. Basically, if you check it, it's gonna use the Minimal APIs template, and if you don't, it's supposed not to. When I unchecked it, I still wondered why I got a project with no Startup :/
I just started learning templates for work and this video helped a bunch! I keep running into an issue though where the options aren't updating. when I do `-h` on my template, I can see the options, but their actual cli names (and shortname) are just not listed. Then when I try to use the options when calling dotnet new by assuming it's the first letter, I get a "not a valid option" error. This seems to happen randomly and only when my template file starts to grow a little. Have you had this issue before?
Is it possible to add content to *existing files* when applying an item template? (Example: a simple service implementation as a template and automatically adding it to Dependency Injection on creation)
The one thing I don't like when it comes to .NET 6 is that it seems, to me anyway, they're trying to be like JS/Python/(Insert other scripting language here) with the no class/namespace on the new templates, so thanks for this I'll be replacing all .NET 6 templates with my own that doesn't try to be something its not.
They are trying to remove some unnecessary boilerplate and make the language more accessible. I personally did not like that they removed the Startup.cs. I think having everything in the Program.cs is messy
I get the more accessible part, the unnecessary part I don't, but we're at completely different programming levels so I get the disconnect there. Just happy I can use a template to bring it all back.
This doesn't explain how you can create custom templates to have different auto generated content like razor pages for crud. This explains only how to put a unicorn in your namespace. WTF
It's so funny that I've been Googling this for the whole week and now you've come to my grace
It's almost like I perfectly planned it with the .NET release date :D
Realize this is an older video but had a use case today for this. Spent the morning trying to create a multi-project template, the "old" way. That template export tool doesn't work well enough for solutions of any complexity, IMHO. Looked up the dotnet new template documentation, and found your video during that search. Microsoft should go a step further and mark the old way as obsolete for dotnet projects in their documentation. (Maybe I'll suggest it in a docs pull request). I now have a multiple project solution template, with references to infrastructure projects in shared folders, and loose files in solution folders. Made a template out of that solution after about 5 minutes of setup. Super fast, super awesome.
totally agree
Thank you so much for this!! My Xamarin apps have a lot of boilerplate that I personally use, and this would save me SO MUCH time spinning up a new project!
For someone always starting projects, trying new things and learning new things, this is a life saver. I wasted no time and made my own. Now when I feel like I have found something I will use in every project, I put it in this template. Best video ever. QOL Game changer!🙃
Where is the documentation link😣
@*# syntax is not recognized (VS, VSC) any ideas?
@Nick Do you have the link for the documentation for templates? I did not see it in the description above.
Awesome, you just uploaded a video right when am looking for one.
Hi Nick. Any chance you could do an up to date version of this video? I have followed the video exactly and this no longer works :( I'm trying to create a template and failing miserably.
how about a multi-project template?
Wow, I'll be using that. 3 quick questions though, does it work with multiple projects in 1 template? What does it do with project names with spaces, because in some places you'd want to convert something like "My Project" to "My_Project", and in others you'd want to leave as-is. And how can you control the substitution on file names?
I'm interested in solution templates aswell, is that possible?
Yes it works, just create the .template.config folder at the solution level, not inside a project
Nice video, covered all the key points
I have checked Microsoft doc for this and I couldn't get the details about this replacement approach. Thanks Nick...
This is great!!!! I needed a video like this. Thank you soo much!!!!!
Is it possible to conditionally add parameters? For example, depending on a selected choice a string parameter will be visible or not
Yes, it's possible, when you create a template from the command line. But it doesn't work when you create a template from the wizard windows. Visual studio didn't implement it and I created a ticket for them with that, still waiting... :/
Thank you Nick!!!!
I like that you don't do stupid "RUclips face" as your thumbnail - based on the fact that your content is gold.
I might be crazy, but I did not figure out where did @Nick put link to documentation? I have tried to google for documentation but I am I am finding a proper documentation. Everything I have found is really short.
hey, i can't find any info about, so i am gonna try it here. When i have the .template.config at solution dir, and i create a new solution/project from the template. The new solution does not get a project added. 0. When i put the .template.config inside the template project. it works great. But i wanna try to get multiple projects to my template. But I cant figure it out. You got any advise?
Any reason why the template wouldn't show up in the Visual Studio Create a new project window? I can create a project from CLI but I'd like to be able to select my template in the UI. Is that not possible without Rider?
Hey @Nick Chapsas Thanks for this... what about multiple projects in a template, like say I want to create a whole SOLID, repository pattern solution as a template? Would be great to share a video for that.
Are you able to build the template project itself with all that parameterized entries, or do you need to generate a project form it to be able to test it?
man i would love to see if you can make a video which uses different types of text templating engine like fluid, mustache , etc different libs and benchmark them to get results for doing same thing to know which is the best templating engine with fast efficient ,etc etc
Awesome video. I wanted a video on this topic. Maybe out of scope but any idea on how to create a solution template with 3 projects for example
Yes. you can create basic projects with reference along with solution file and place template folder on root. Try it.
@*#if is not recognized and causes build to fail, any ideas? Using a .NET 6 WebApi project and I'm trying to put the conditional on the Program.cs.
Thank you so much for providing such an useful information. Any pointer for creating multi project templates.
My template project has git history. When I install the template, I also seem to bring over the git history. The result is running dotnet new mytemplate -0 "mynewapp" creates a new project but it contains the git history of the template. Is there a way for me to ignore the .git folder when installing the template?
wow that's reallly dope!!! thanks!!!!
Thank you for this video it helps me a lot. I'm having trouble with "#if DEBUG" syntax that it seems to be removed when I create a new project from the template, any work around?
Really good one :) thanks!
Is there a way to share the templet outside of Nuget? My org. is not going to let me share via new get but Id like to distribute temples to my team.
You can specify your own nuget source. That can be a local folder (but then sending updates to your team could be a problem) or your own nuget server hosted behind a VPN or something. This is what my team does. Then you and your team can add the nuget source in your IDE! Makes life so much easier. Otherwise, you'll probably need to make a git repo and your team can just pull the source and install locally as needed.
@@siredwin12 The team has a mapped network drive , Ill try that. Thanks
Thank you so much, I got tired from writing the same code again and again. this video really helped me a lot
I have a question : Is there a way to add/ remove package?
Eg: In the Swagger example, is there a way to remove the package from the project (csproj) when the enable swagger choice is false ?
Replace the entire line that installs swagger with nothing if the condition is not enabled.
Life saver ❤❤
So I wasn't the only one to dislike Startup missing in the template. :)
It's a ridiculous decision.
@@jarrichvdv Couldn't agree more. When I tried creating an API project for test purposes, I saw a checkbox telling me it's for using minimal APIs.
Basically, if you check it, it's gonna use the Minimal APIs template, and if you don't, it's supposed not to. When I unchecked it, I still wondered why I got a project with no Startup :/
Yeah even for me, that was a bit much
When I created a new console project, I was like "they even felt the need to change this one?"
So they removed startup alongside class templates?!
I just started learning templates for work and this video helped a bunch! I keep running into an issue though where the options aren't updating. when I do `-h` on my template, I can see the options, but their actual cli names (and shortname) are just not listed. Then when I try to use the options when calling dotnet new by assuming it's the first letter, I get a "not a valid option" error. This seems to happen randomly and only when my template file starts to grow a little. Have you had this issue before?
dotnet pack, it doesnt work for me raised error like this:
.... error MSB4057: The target "pack" does not exist in the
project.
somebody could help?
Man I love you ❤ just the video I need it
thanks excelent video, but I have s solution and two proyects, do you know how create de template.json?
Wow .
Now that's a cool one 🙂
Is it possible to add content to *existing files* when applying an item template? (Example: a simple service implementation as a template and automatically adding it to Dependency Injection on creation)
Not with this technology
nice job!
The one thing I don't like when it comes to .NET 6 is that it seems, to me anyway, they're trying to be like JS/Python/(Insert other scripting language here) with the no class/namespace on the new templates, so thanks for this I'll be replacing all .NET 6 templates with my own that doesn't try to be something its not.
They are trying to remove some unnecessary boilerplate and make the language more accessible. I personally did not like that they removed the Startup.cs. I think having everything in the Program.cs is messy
I get the more accessible part, the unnecessary part I don't, but we're at completely different programming levels so I get the disconnect there. Just happy I can use a template to bring it all back.
Thanks for sharing content to us, master!!!
Hi.. Awesome video. Will this work also on visual studio for mac?
Why not?
I don't see any platform specific code here.
Unless Apple or Microsoft just want to be dicks.
Again ;-)
@@igorthelight 😅 that's true. Will see
Hey, guys! How to we replace file scoped namespace with a regular one, if target framework is set to net5.0?
You have to add if checks to support both options
Thanks
How to remove Template?
🤣It's a little bit wired but it is what it is.
This doesn't explain how you can create custom templates to have different auto generated content like razor pages for crud. This explains only how to put a unicorn in your namespace. WTF