Project Templates in Visual Studio 2015

Play Project Templates in Visual Studio 2015
Sign in to queue


Knowing your tool is essential to being productive but who has time to watch long videos?  Get up to speed quick with short video lessons and get on to coding.  Check out the other videos at the video blog Visual Studio Shorts.

Script (for reference only):

Welcome I am James Sturtevant (@aspenwilder).

Today, we are going to take a look at how to create projects using Visual Studio Templates.  Visual Studio templates are great because the do the scaffolding of projects for us so we don't have to write the boiler plate code.  They also help us set up our project in a familiar format each time, whether that be a best practice or a team standard, allowing us to be consistent across projects.

We will start in the file menu, where we can create new projects.  Most of the time, the easiest way is through the new project dialog. As I can get to most things there, I almost never choose the other options here.  So let's start there.

Once the dialog is open we will see a variety of options.  We are most interested in templates as we want to start a brand new project.  By clicking on the C# node we can see all the project templates that are available to us in the C# language.  But that is not the only templtes we have access to.  If you're game developer you can get templates for Unity, and there is also F#, Javascript, Python and many more. 

At the top you can sort your projects by the .net frame work if you using .NET project template types and you can also search for templates by name.  This is very handy if you know the exact template you want but are not sure where it lives.  For instance if I type console I will get a list of all types of console projects I have access to including Azure WebJob console project template.

The next cool feature in this dialog is the samples.  If you haven't installed any yet you may not see any listed.  These are great for learning a new library or framework.  You can see a sample on how to program in C# or a full end to end sample. 

 So far I have only shown you the out of the box templates that ship with visual studio but there are thousands of other templates and samples made available by the community.  Here you will find templates for everything from IoT Projects to react.js starter kits.  You can also find samples on how to accomplish specific tasks such as how to make a transparent bitmap in F#.

Let's create our first project using a template.  Because I am a ASP.NET geek we will create a new web project.  you can rename your project and also change where it lives.  Visual studio creates a solution file for the project and groups all projects together.  This allows you to keep code in separate libraries but edit them under one roof.  You also can automatically add the project to source control, which is always a good idea.

This screen is a great example of the wizards that project templates can have.  They allow the template to gather just a bit more information about what you are building so they can set it up in the best way possible.  As you can see here they can be quite complex.  I'm going to add a unit test project to my solution as testing is always a good idea.  I could also auto deploy to azure right through this wizard.

And Visual studio is off create our project for us.  This takes a few second and since this is the first project we have created we are prompted to select our favorite version control.  I am going to choose git.  As you can see if scolded out a ton of files and folders for us in the solution folder.  If we open up the folder where the project is created you can see the solution structure and also how VS created a git project for us including a .gitignore.

Most of the templates you use will be functional right tout of the box.  As you can see when I launch the website I get a MVC website that has place holders for me to get started!

And now we have created our first Visual Studio project.  As you can see it is very easy to get started with new projects and there are plenty of ways to get new template types for any project you work on whether it is C#, Python, node.js, etc.   We didn't have time to cover it today but you can also create your own templates, which is very powerful.  Check back later for a video on how to create your own. We will see you next time when we over how to install extensions.   Leave any comments or feedback, especially around topics you want to see.  Happy Coding!



Right click to download this episode

The Discussion

  • User profile image

    Why don't I have any templates?

  • User profile image

    At 1:37 he clicks on "Online" but does not make specific reference to what he is doing. I had to rewind 3 times to catch this. Otherwise it leaves a person thinking, "how did he get to these templates"? Critical oversite when the title of the article is "Project Templates". Once you are aware of this it is obvious, but if I was already aware of this I would not be here.

Add Your 2 Cents