The first Visual Studio Project template (created by wizard)

Source: Internet
Author: User

As mentioned above, this series mainly discusses how to create a project template. There are two ways to create a project template: Wizard creation and manual creation.

Now let's create a simple project template. Through this simple example, let's take a look at the creation process of the two creation methods.

This article first describes the first method of creation, which is created by the wizard.

1. Preparation for template creation:

A template is essentially a template source (here I have defined a concept to indicate the template preparation content). Therefore, we must first make such a source, assume that the company has a lot of Web projects to do now. The first step for many project teams to develop Web projects is to create a multi-layer framework for the project. These layers have complicated relationships, different assemblies will be referenced at each layer. If there is a general template, it is not easy for the project team to build a framework? There are many modes and layers in Web development. This is not the topic of this series. It can be simplified for examples and help me illustrate the issues that this article focuses on, assume that all these projects require the same two-layer simple architecture.

First, create a template source file of such a two-layer architecture. Here it is called the template source, because it is only the first step in template creation. The first step is not called the project template, because the Visual Studio template mechanism does not know it.

This template consists of a Class Library and a Web project.

Modify the namespace to suit your needs

The final structure is as follows:

2. Use the "Export template" Wizard of Visual Studio to create a project template.

Follow "File"-> "Export Template" to open the wizard-> select "Project Template" to open the first step

At the bottom of the page, we can see that the biggest disadvantage of creating a Project template by using a wizard is that you can only create a template for a single Project. Regardless of its limitations, let's just look at what the generated template is. Therefore, choose DataService to proceed to the next step.

The entered content items are not explained, because they can be seen at a glance. The two check boxes here explain a little. The first one indicates that the files are automatically copied to the user template directory after being generated (refer to the previous article ), the second one indicates that the above "Output location" Directory will be automatically opened after generation. In fact, you can verify it by yourself.

We can take a look at this dataservicetemplate.zip, which is named "Template name" we previously defined and is a standard ZIP package (other compression formats are not supported). We decompress this package, check the content.

I first come to the conclusion that this package consists of three parts: the template source (DataService. csproj points to the project, open it is the model we previously made) + template metadata file (MyTemplate. vstemplate) + templates support files (two png images ). The template metadata file is the core and used to organize all other parts.

At this time, we opened the new project wizard and found that our template appeared. At the same time, it is noted that its icons and previews are all the images we set during creation. In addition, pay attention to the red arrow points. These points will be involved in the following series.

We use this project template to create a project and find that it is the effect of the template we have defined, namespace, included files, added references, and so on. We can verify it one by one.

3. Conclusion:

1. The Wizard creation method is simple and intuitive. You can quickly create the desired template and deploy it conveniently and quickly. You only need to know some basic concepts, that is, the content of the first article can be applied to the project. The production item template wizard is not introduced here. You can try it and try the two concepts at the same time.
2. The biggest drawback of the wizard method is that you can only create project templates based on a single project. You can't do anything about templates based on multiple projects.
3. The template package is a ZIP package that contains the template source file, template metadata file, and template support file. The template metadata file is used to index the content of all other template packages.

 

From: http://www.ethan-woo.com/post/2011/04/24/First-VisualStudio-Template-By-Wizard.aspx

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.