How to define a multi-project template in Visual Studio vs

Source: Internet
Author: User

Https://msdn.microsoft.com/en-us/library/ms185308.aspx

Multi-Project Templates act as containers for the or more projects. When a project based on a multi-project template are created from the New Project dialog box, every project Template is added to the solution.

A multi-project template must include the following items, compressed into a. zip file:

    • A root. vstemplate file for the entire multi-project template. This is root. vstemplate file contains the metadata that is the New Project dialog box displays, and specifies where to Find the. vstemplate files for the projects in this template. This file must is located at the root of the. zip file.

    • One or more folders this contain the files that is required for a complete project template. This includes all code files for the project, and also a. vstemplate file for the project.

For example, a multi-project template. zip file with projects could has the following files and directories:

Multiprojecttemplate.vstemplate

\project1\project1.vstemplate

\project1\project1.vbproj

\project1\class.vb

\project2\project2.vstemplate

\project2\project2.vbproj

\project2\class.vb

The root. vstemplate file for a multi-project template differs from a single-project template in the following ways:

    • The Type attribute of the VSTemplate element contains The value projectgroup . For example:

        
       <vstemplate version= "2.0.0" type= "ProjectGroup" xmlns= "/http schemas.microsoft.com/developer/vstemplate/2005 
    • The TemplateContent element contains a ProjectCollection element that have one or more ProjectTemplateLink E Lements that define the paths to the. vstemplate files of the included projects. For example:

        
       <TemplateContent> <ProjectCollection> <ProjectTemplateLink> Project1\project1.vstemplate </ProjectTemplateLink> <ProjectTemplateLink> P Roject2\project2.vstemplate </ProjectTemplateLink> </projectcollection></templatecontent>

Multi-Project templates also behave differently than normal templates. Multi-Project templates has the following unique characteristics:

    • Individual projects in a multi-project template cannot is assigned names by the New Project dialog box. Instead, use the ProjectName attribute in the ProjectTemplateLink element to specify the name of each p Roject. For more information, see the first example of the following section.

    • Multi-Project templates can contain projects written in different languages, but the entire template itself can only be PU T in one category by using the ProjectType element.

To create a multi-project template
    1. Create the projects to include in the multi-project template.

    2. Create. vstemplate files for every project. For more information, see how To:create Project Templates.

    3. Create a root. vstemplate file, contain the metadata for the multi-project template. For more information, see the first example of the following section.

    4. Select the files and folders to include in your template, right-click the selection, click Sendto, and then clic K Compressed (zipped) Folder. The files and folders is compressed into a. zip file.

    5. Put the. zip template file in the Visual Studio project template directory. By default, this directory is \my Documents\Visual Studio Version\templates\projecttemplates\.

Example

This example shows a basic multi-project root. vstemplate file. In this example, the template contains the projects, my Windows application and my Class Library. The ProjectName attribute on the ProjectTemplateLink element sets the name of Visual Studio to assign T His project. If the ProjectName attribute does not exist, the name of the. vstemplate file is used as the project name.

<vstemplate version= "2.0.0" type= "ProjectGroup" xmlns= "http://schemas.microsoft.com/developer/vstemplate/    2005 ">    <TemplateData>        <name>multi-project Template sample</name>        < Description>an example of a multi-project template</description>        <Icon>Icon.ico</Icon>        <ProjectType>VisualBasic</ProjectType>    </TemplateData>    <TemplateContent>        <ProjectCollection>            <projecttemplatelink projectname= "My Windows Application" >                Windowsapp\mytemplate.vstemplate            </ProjectTemplateLink>            <projecttemplatelink projectname= "My Class Library ">                classlib\mytemplate.vstemplate            </ProjectTemplateLink>        </ Projectcollection>    </TemplateContent></VSTemplate>
Example

This example uses the SolutionFolder element to divide the projects into the groups, Math Classes and graphics Classes. The template contains four projects, and the which is placed in each solution folder.

<vstemplate version= "2.0.0" type= "ProjectGroup" xmlns= "http://schemas.microsoft.com/developer/vstemplate/2005" > <TemplateData> <name>multi-project Template sample</name> <description>an ex Ample of a multi-project template</description> <Icon>Icon.ico</Icon> <projecttype>v            isualbasic</projecttype> </TemplateData> <TemplateContent> <ProjectCollection>                    <solutionfolder name= "Math Classes" > <projecttemplatelink projectname= "MATHCLASSLIB1" > Mathclasslib1\mytemplate.vstemplate </ProjectTemplateLink> <project Templatelink projectname= "MathClassLib2" > Mathclasslib2\mytemplate.vstemplate </pr                ojecttemplatelink> </SolutionFolder> <solutionfolder name= "Graphics Classes" > <projecttemplatelinK projectname= "GRAPHICSCLASSLIB1" > Graphicsclasslib1\mytemplate.vstemplate </proje cttemplatelink> <projecttemplatelink projectname= "GraphicsClassLib2" > GRAPHICSC Lasslib2\mytemplate.vstemplate </ProjectTemplateLink> </SolutionFolder> </ Projectcollection> </TemplateContent></VSTemplate>

Multi-Project Templates act as containers for the or more projects. When a project based on a multi-project template are created from the New Project dialog box, every project Template is added to the solution.

A multi-project template must include the following items, compressed into a. zip file:

    • A root. vstemplate file for the entire multi-project template. This is root. vstemplate file contains the metadata that is the New Project dialog box displays, and specifies where to Find the. vstemplate files for the projects in this template. This file must is located at the root of the. zip file.

    • One or more folders this contain the files that is required for a complete project template. This includes all code files for the project, and also a. vstemplate file for the project.

For example, a multi-project template. zip file with projects could has the following files and directories:

Multiprojecttemplate.vstemplate

\project1\project1.vstemplate

\project1\project1.vbproj

\project1\class.vb

\project2\project2.vstemplate

\project2\project2.vbproj

\project2\class.vb

The root. vstemplate file for a multi-project template differs from a single-project template in the following ways:

    • The Type attribute of the VSTemplate element contains The value projectgroup . For example:

        
       <vstemplate version= "2.0.0" type= "ProjectGroup" xmlns= "/http schemas.microsoft.com/developer/vstemplate/2005 
    • The TemplateContent element contains a ProjectCollection element that have one or more ProjectTemplateLink E Lements that define the paths to the. vstemplate files of the included projects. For example:

        
       <TemplateContent> <ProjectCollection> <ProjectTemplateLink> Project1\project1.vstemplate </ProjectTemplateLink> <ProjectTemplateLink> P Roject2\project2.vstemplate </ProjectTemplateLink> </projectcollection></templatecontent>

Multi-Project templates also behave differently than normal templates. Multi-Project templates has the following unique characteristics:

    • Individual projects in a multi-project template cannot is assigned names by the New Project dialog box. Instead, use the ProjectName attribute in the ProjectTemplateLink element to specify the name of each p Roject. For more information, see the first example of the following section.

    • Multi-Project templates can contain projects written in different languages, but the entire template itself can only be PU T in one category by using the ProjectType element.

To create a multi-project template
    1. Create the projects to include in the multi-project template.

    2. Create. vstemplate files for every project. For more information, see how To:create Project Templates.

    3. Create a root. vstemplate file, contain the metadata for the multi-project template. For more information, see the first example of the following section.

    4. Select the files and folders to include in your template, right-click the selection, click Sendto, and then clic K Compressed (zipped) Folder. The files and folders is compressed into a. zip file.

    5. Put the. zip template file in the Visual Studio project template directory. By default, this directory is \my Documents\Visual Studio Version\templates\projecttemplates\.

Example

This example shows a basic multi-project root. vstemplate file. In this example, the template contains the projects, my Windows application and my Class Library. The ProjectName attribute on the ProjectTemplateLink element sets the name of Visual Studio to assign T His project. If the ProjectName attribute does not exist, the name of the. vstemplate file is used as the project name.

<vstemplate version= "2.0.0" type= "ProjectGroup" xmlns= "http://schemas.microsoft.com/developer/vstemplate/    2005 ">    <TemplateData>        <name>multi-project Template sample</name>        < Description>an example of a multi-project template</description>        <Icon>Icon.ico</Icon>        <ProjectType>VisualBasic</ProjectType>    </TemplateData>    <TemplateContent>        <ProjectCollection>            <projecttemplatelink projectname= "My Windows Application" >                Windowsapp\mytemplate.vstemplate            </ProjectTemplateLink>            <projecttemplatelink projectname= "My Class Library ">                classlib\mytemplate.vstemplate            </ProjectTemplateLink>        </ Projectcollection>    </TemplateContent></VSTemplate>
Example

This example uses the SolutionFolder element to divide the projects into the groups, Math Classes and graphics Classes. The template contains four projects, and the which is placed in each solution folder.

<vstemplate version= "2.0.0" type= "ProjectGroup" xmlns= "http://schemas.microsoft.com/developer/vstemplate/2005" > <TemplateData> <name>multi-project Template sample</name> <description>an ex Ample of a multi-project template</description> <Icon>Icon.ico</Icon> <projecttype>v            isualbasic</projecttype> </TemplateData> <TemplateContent> <ProjectCollection>                    <solutionfolder name= "Math Classes" > <projecttemplatelink projectname= "MATHCLASSLIB1" > Mathclasslib1\mytemplate.vstemplate </ProjectTemplateLink> <project Templatelink projectname= "MathClassLib2" > Mathclasslib2\mytemplate.vstemplate </pr                ojecttemplatelink> </SolutionFolder> <solutionfolder name= "Graphics Classes" > <projecttemplatelinK projectname= "GRAPHICSCLASSLIB1" > Graphicsclasslib1\mytemplate.vstemplate </proje cttemplatelink> <projecttemplatelink projectname= "GraphicsClassLib2" > GRAPHICSC Lasslib2\mytemplate.vstemplate </ProjectTemplateLink> </SolutionFolder> </ Projectcollection> </TemplateContent></VSTemplate>

How to define a multi-project template in Visual Studio vs

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.