zoukankan      html  css  js  c++  java
  • 如何在Visual Studio VS中定义多项目模板

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

    Multi-project templates act as containers for two or more projects. When a project based on a multi-project template is created from the New Project dialog box, every project in the 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 root .vstemplate file contains the metadata that the New Project dialog box displays, and specifies where to find the .vstemplate files for the projects in this template. This file must be located at the root of the .zip file.

    • One or more folders that contain the files that are 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 that has two projects could have the following files and directories:

    MultiProjectTemplate.vstemplate

    Project1Project1.vstemplate

    Project1Project1.vbproj

    Project1Class.vb

    Project2Project2.vstemplate

    Project2Project2.vbproj

    Project2Class.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 has one or more ProjectTemplateLink elements that define the paths to the .vstemplate files of the included projects. For example:

       
       
      <TemplateContent>
          <ProjectCollection>
              <ProjectTemplateLink>
                  Project1Project1.vstemplate
              </ProjectTemplateLink>
              <ProjectTemplateLink>
                  Project2Project2.vstemplate
              </ProjectTemplateLink>
          </ProjectCollection>
      </TemplateContent>
      

    Multi-project templates also behave differently than normal templates. Multi-project templates have the following unique characteristics:

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

    • Multi-project templates can contain projects written in different languages, but the entire template itself can only be put 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 that to contain the metadata for the multi-project template. For more information, see the first example in the following section.

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

    5. Put the .zip template file in the Visual Studio project template directory. By default, this directory is My DocumentsVisual Studio VersionTemplatesProjectTemplates.

    Example

    This example shows a basic multi-project root .vstemplate file. In this example, the template contains two projects, My Windows Application and My Class Library. The ProjectName attribute on the ProjectTemplateLink element sets the name for Visual Studio to assign this 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">
                    WindowsAppMyTemplate.vstemplate
                </ProjectTemplateLink>
                <ProjectTemplateLink ProjectName="My Class Library">
                    ClassLibMyTemplate.vstemplate
                </ProjectTemplateLink>
            </ProjectCollection>
        </TemplateContent>
    </VSTemplate>
    

    Example

    This example uses the SolutionFolder element to divide the projects into two groups, Math Classes and Graphics Classes. The template contains four projects, two of which are 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 example of a multi-project template</Description>
            <Icon>Icon.ico</Icon>
            <ProjectType>VisualBasic</ProjectType>
        </TemplateData>
        <TemplateContent>
            <ProjectCollection>
                <SolutionFolder Name="Math Classes">
                    <ProjectTemplateLink ProjectName="MathClassLib1">
                        MathClassLib1MyTemplate.vstemplate
                    </ProjectTemplateLink>
                    <ProjectTemplateLink ProjectName="MathClassLib2">
                        MathClassLib2MyTemplate.vstemplate
                    </ProjectTemplateLink>
                </SolutionFolder>
                <SolutionFolder Name="Graphics Classes">
                    <ProjectTemplateLink ProjectName="GraphicsClassLib1">
                        GraphicsClassLib1MyTemplate.vstemplate
                    </ProjectTemplateLink>
                    <ProjectTemplateLink ProjectName="GraphicsClassLib2">
                        GraphicsClassLib2MyTemplate.vstemplate
                    </ProjectTemplateLink>
                </SolutionFolder>
            </ProjectCollection>
        </TemplateContent>
    </VSTemplate>
    

    Multi-project templates act as containers for two or more projects. When a project based on a multi-project template is created from the New Project dialog box, every project in the 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 root .vstemplate file contains the metadata that the New Project dialog box displays, and specifies where to find the .vstemplate files for the projects in this template. This file must be located at the root of the .zip file.

    • One or more folders that contain the files that are 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 that has two projects could have the following files and directories:

    MultiProjectTemplate.vstemplate

    Project1Project1.vstemplate

    Project1Project1.vbproj

    Project1Class.vb

    Project2Project2.vstemplate

    Project2Project2.vbproj

    Project2Class.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 has one or more ProjectTemplateLink elements that define the paths to the .vstemplate files of the included projects. For example:

       
       
      <TemplateContent>
          <ProjectCollection>
              <ProjectTemplateLink>
                  Project1Project1.vstemplate
              </ProjectTemplateLink>
              <ProjectTemplateLink>
                  Project2Project2.vstemplate
              </ProjectTemplateLink>
          </ProjectCollection>
      </TemplateContent>
      

    Multi-project templates also behave differently than normal templates. Multi-project templates have the following unique characteristics:

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

    • Multi-project templates can contain projects written in different languages, but the entire template itself can only be put 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 that to contain the metadata for the multi-project template. For more information, see the first example in the following section.

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

    5. Put the .zip template file in the Visual Studio project template directory. By default, this directory is My DocumentsVisual Studio VersionTemplatesProjectTemplates.

    Example

    This example shows a basic multi-project root .vstemplate file. In this example, the template contains two projects, My Windows Application and My Class Library. The ProjectName attribute on the ProjectTemplateLink element sets the name for Visual Studio to assign this 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">
                    WindowsAppMyTemplate.vstemplate
                </ProjectTemplateLink>
                <ProjectTemplateLink ProjectName="My Class Library">
                    ClassLibMyTemplate.vstemplate
                </ProjectTemplateLink>
            </ProjectCollection>
        </TemplateContent>
    </VSTemplate>
    

    Example

    This example uses the SolutionFolder element to divide the projects into two groups, Math Classes and Graphics Classes. The template contains four projects, two of which are 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 example of a multi-project template</Description>
            <Icon>Icon.ico</Icon>
            <ProjectType>VisualBasic</ProjectType>
        </TemplateData>
        <TemplateContent>
            <ProjectCollection>
                <SolutionFolder Name="Math Classes">
                    <ProjectTemplateLink ProjectName="MathClassLib1">
                        MathClassLib1MyTemplate.vstemplate
                    </ProjectTemplateLink>
                    <ProjectTemplateLink ProjectName="MathClassLib2">
                        MathClassLib2MyTemplate.vstemplate
                    </ProjectTemplateLink>
                </SolutionFolder>
                <SolutionFolder Name="Graphics Classes">
                    <ProjectTemplateLink ProjectName="GraphicsClassLib1">
                        GraphicsClassLib1MyTemplate.vstemplate
                    </ProjectTemplateLink>
                    <ProjectTemplateLink ProjectName="GraphicsClassLib2">
                        GraphicsClassLib2MyTemplate.vstemplate
                    </ProjectTemplateLink>
                </SolutionFolder>
            </ProjectCollection>
        </TemplateContent>
    </VSTemplate>
    
  • 相关阅读:
    7zip 自解压安装程序
    修改当前启动菜单项的HyperVisorLaunchType
    VMware 虚拟镜像转 Hyper-V(Win10/2016)
    旋转基础知识
    变换及移动基础知识
    文字及排版章末小结
    文字排版相关
    文字变形及封套扭曲
    LinQ学习笔记.
    PHP笔记-PHP中Web Service.
  • 原文地址:https://www.cnblogs.com/haoliansheng/p/5667113.html
Copyright © 2011-2022 走看看