Saturday 23 December 2017

How to create Visual Studio Project Templates?

Highlights

In this document we will found answer of following questions:
  • What is Visual Studio Project Templates? 
  • Where to found, real example? 
  • Can we create something like that yourself? 
  • Where to start? 
  • What we will able to do after visiting given reference? 
  • How to create a new project template, only .csproj? 
  • How to create .VSIX extension to deploy project template? 
  • How to create a solution (.sln) template with multiple projects (.csproj)? 


What is Visual Studio Project Templates?

It is predefined project with limited base resources, that provide good starting point for programmer to begin creating visual studio projects or expanding current visual studio projects.




Where to found, real example?

Whenever we create a new project through visual studio, we use predefined template given by Microsoft Visual Studio.








Can we create something like that yourself?

Yes




Where to start?

Self-learning Reference:
https://msdn.microsoft.com/en-us/library/ms247121.aspx
https://docs.microsoft.com/en-us/visualstudio/extensibility/creating-custom-project-and-item-templates








What we will able to do after visiting given reference?

We can create
  • An individual project (.csproj) template. 
  • A solution(.sln) with multiple projects(.csproj) template. 


Let's see in action
There are 2 ways to do it
  • Create a template project by exporting template from any of .csproj project and paste in specific folder, from where Visual studio can read and parse template to prompt in to New Project window. Somehow this process is manually, but works smoothly. 
  • Export a template from .csproj project and create a Visual studio extension (.VSIX) and distribute it to coworker so they can install it by clicking once and they will get template in new project window. Little bit more afford then manually process but seems smart solution. 
We will cover both the way in action.

How to create a new project template, only .csproj?

Prerequisite
  • Visual studio 2017 
  • Visual Studio Extensibility Templates 


How to create a new project template, only .csproj?
How to create .VSIX extension to deploy project template?
How to create a solution (.sln) template with multiple projects (.csproj)? 

Watch in YouTube