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>
    
  • 相关阅读:
    POJ 1386 Play on Words(单词建图+欧拉通(回)路路判断)
    HTTP协议详解??
    Python 中三大框架各自的应用场景??
    django 开发中数据库做过什么优化??
    谈一下你对 uWSGI 和 nginx 的理解??
    django 中间件的使用??
    Flask 中请求钩子的理解和应用?
    七层模型? IP ,TCP/UDP ,HTTP ,RTSP ,FTP 分别在哪层?
    说说 HTTP 和 HTTPS 区别??
    hasattr() getattr() setattr() 函数使用详解??
  • 原文地址:https://www.cnblogs.com/haoliansheng/p/5667113.html
Copyright © 2011-2022 走看看