Sunday, March 25, 2012

Understanding Visual Studio Item and Project Template Categorization

If you are creating your own Visual Studio Item or Project Templates, it is worthwhile to understand how Visual Studio itself categorizes its content.

Interestingly enough, there is actually nothing in the .vstemplate file which explicitly forces the categorization of the content into the appropriate navigational structure when you Add a New Item or create a New Project.  Instead, the categorization is based solely on folder structure!

Therefore, the best way to get an understanding of the required folder structure for your own Item and Project Templates is to look at the way that Visual Studio internally utilizes its folder structure.

If we look at the Item Template folder structure, we can see that the top level folder structure is categorized based on the various project types.  Some are categorized by the actual language such as CSharp or VisualBasic, while others are categorized by their actual project type such as Test or Web.

If we dig a little deeper into the actual folder structure for a particular language such as CSharp, we will see the following folder structure:

For the language, we see the various project types mapping to the project categorizations we normally see when we create a New Project within Visual Studio or Add a New Item within Visual Studio.

The only major confusing project type that arises is the use of the Web project type.  As you noticed from the earlier screenshot, Web is a project type at the root of the folder hierarchy as well as residing beneath the CSharp folder structure.

As it turns out, the Web folder residing at the root of the folder structure corresponds to Web Sites, while the Web folder beneath the CSharp directory corresponds to Web Applications.  Therefore, the languages for CSharp and VisualBasic actually reside beneath  the Web folder structure when creating Web Sites.

Other than that, everything else in the folder structure should be pretty self explanatory!

Hopefully this gives you a little bit more insight when creating your own Item and Project Templates for use within your own organization.  As long as you are able to follow this folder structure for your own Item and Project Templates, you should have no trouble getting your Items and Projects to appear in the correct locations in the Visual Studio Installed Templates Navigation Tree!

No comments:

Post a Comment