That seemed really useful so here I’m going to show you how you can do something similar using existing features of Visual Studio. I’ll be using version 2017 but it wouldn’t surprise me if this existed in prior versions too.
OK, so what do I want to achieve? I’d like to create a project which is console based, uses the .NET framework and comes with a baked in class called Runner to execute code, much like Jesse’s. I also want to hook everything together so that I can run it immediately if I choose to.
The first step is to create something just like that but here’s mine in case you’re wondering:
static void Main(string args)
Runner run = new Runner();
public class Runner
public void Run()
Console.WriteLine("This is the run method.");
Don’t forget to save your project before you move onto the next step.
- Under the Project menu, choose Export Template…
- Leave the choice of Project Template selected and click “Next >”
- On the screen that appears, give the template a name, add a description and if you like, choose icon and preview images. Everything else can be left as is. In my case, I named my project as ConsoleRunner so I didn’t want to change that name.
- Click Finish to generate your template.
Where are the templates stored?
After clicking Finish, you will be presented with the folder in which the template has been added. On my machine that’s here:
C:\Users\[user name]\Documents\Visual Studio 2017\My Exported Templates
As you can see, the template is stored as a zip file, but what’s inside?
Now, when you go to create a project, you have this new option:
Written by Stephen Moon
email: stephen at logicalmoon.com