 Last time in our template many series, we talked about how to create your own custom template, but how do you get it to actually show up in Visual Studio? Find out on this episode of Visual Studio Toolbox. Hey, everyone. Welcome back to another episode of Visual Studio Toolbox. I'm your host, Leslie Richardson, and I'm joined yet again by Senior Program Manager, Syed Hashini. Welcome back. Hello. Thanks for having me. This time around, we're going to take the.NET template that we created in the previous episode and get it to work for Visual Studio, right? That's right. When you create a template for.NET new, there are a couple of customizations that need to be made to get it to appear in Visual Studio. Those are pretty simple and should be pretty quick. We're going to run through those real quick, and we'll show exercising that Project Template in Visual Studio as well. All right. All right. Let's go ahead and get started here. I've got that solution opened up that we've been working on here. Whenever we're using the template engine to create a template, I showed you the basics of how to get a template working for.NET new. But what we need to do is actually modify. We're going to add a couple of additional files here. Let me go into my samples here and the source, under Content and the template config. We can see there's a couple of additional files, so the ide.host.json file. That's the one that we'll be adding here. So I'm going to go ahead and go into that. I'm going to copy the schema file, the schema declaration for that. Let me go and add this to the correct location here, so my console one. Let's get rid of that other one. All right. I'm going to create the ide.host.json file here. All right. Drag those back into Visual Studio itself, so I can start working on that. I'm going to go ahead and add that schema declaration there. So now with the ide.host.json, what this does is this is an indication that you want your template to appear in the various different IDEs that support it. So those IDs that support this are Visual Studio 2019, and also Visual Studio for Mac, and also I think JetBrainsRider has support for these custom templates as well. One thing that I'm not sure if we covered yet was, how do I turn on the feature for your .NET new templates to show up in Visual Studio? So you'll go into Tools Options and then go down to Preview Features, and then scroll down to where you see showall.NET Core Templates. So definitely make sure that that's checked in, and then the 16.9 that should be checked by default. All right. So I went ahead and I added this ide.host.json file. So without, if this file is not there, Visual Studio believes that this template hasn't been designed to be used within Visual Studio, so they just won't appear unless you create this file. All right. So we did that. Now let's go back. Let's take a look at where we're at. Okay. So now what I need to do is I need to go ahead and rebuild. I need to rebuild the Nougat package so that way we'll have the ide.host.json file there. So I've rebuilt it. Now I'm just going to go ahead and install this as well. So it's .NET new install and then path to Nougat package file. I'm going to install that. You can see that it has been successfully installed. Let me restart my Visual Studio here. So yeah, whenever you install a new template, you'll have to restart Visual Studio to get it to appear. All right. So let me just do a, let me clear out my filter here. Earlier, we talked about the classifications. So this is where the classifications will appear, and that's how you can filter them. So for example, I can filter the console because that's what I indicated in my template.json. And now we can see I've got my project here. But what I'm noticing is, you know, it's just got the regular kind of default icon here. And you know, that's not really the right experience. I'm just going to go ahead and close out of this. We'll add a different icon and then come back again. So let's go ahead and close out of that. I'm just going to go ahead and download the icon.png file that's here and in my samples repository here. And this image, it has to be, you know, in or under the template.json, sorry, .template.config folder there. So I put it directly in the .template.config folder there. Let me open up that file one more time. That's it. Now I'm going to go ahead and edit my ide.host.json file to add the icon property here. And then it was just, I think it was just icon.png if I'm not mistaken. Yeah. A very inspiring name. Yeah, very, very. Let me go ahead and save that. So what we'll do is, we're going to just redo the whole thing here. So I'm going to reset my templates. Then I'm going to repack it. And then I'm going to go ahead and install this. And if I was doing this myself, I would just wrap these three commands into one. So I would just have one command, was reset template semicolon, and then this command semicolon, and then this command. And then when you hit enter, it will just run all three at the same time. All right, so now we've reinstalled our template and hopefully we've got that kind of custom icon appearing there. So let's go ahead and fire that up. So let's go ahead and create a new project. All right, so here we go. So now we can see I've got the custom icon that appears there. It looks like some kind of screwdrivers or something. It looks very legit. Yeah, yeah. Okay, so here's another thing that I'm noticing here. So now for the project name, I just get project five. Maybe I want to kind of customize that a little bit as well. So let me show you how you can do that. So that is actually with inside the template.json file. So let me open that guy back up one more time. So template.json. All right, there's another property that we can add here. It's default name. So I'll say the default name is just console and then a visual studio will add the one, two and three basically it's going to close out of that. We pack it and then reinstall that. All right, let's try it. And definitely make sure to close visual studio while you're kind of doing this. If I had kept visual studio open at that time, then then these changes would not appear. So we saw earlier it said, you know, like project one or something like that. But now I'm getting something that's a little bit better here, console one. Let's say demo console. Let's go ahead and create this project. All right, let's go ahead and just debug this. All right, hello from the demo console. So that's exactly what we expected there. And you know, we had kind of a first class support in visual studio with that kind of custom icon and customizing the project name. And you know, templates that are created with .NET new, you know, they're a first class citizen just like templates that have been created by Microsoft themselves. So in the upcoming videos, we'll show how to do parameters and kind of make these templates even more better. That's exciting. And I mean, just that template JSON file in general just seems so important. It's like the blueprint for all of it. That's right, that's right. And you know, once again, whenever you're editing one of those JSON files, you know, whether it's the template.json or the IDE.host.json, you always wanna make sure to have the correct schema declaration defined in there. So you'll get the right kind of errors and warnings and also the hints with the intelligence. Make sense. Great, well, I can't wait to see what we're gonna do next time with the templates. As you mentioned, we're gonna be talking about parameters and other cool things. So until then, happy coding. I'll see you guys in the next video. Bye.