博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
如何在Visual Studio VS中定义多项目模板
阅读量:6720 次
发布时间:2019-06-25

本文共 10410 字,大约阅读时间需要 34 分钟。

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

\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:

     
     
  • 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:

     
     
    Project1\Project1.vstemplate
    Project2\Project2.vstemplate

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 .

  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 Documents\Visual Studio Version\Templates\ProjectTemplates\.

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.

 
 
Multi-Project Template Sample
An example of a multi-project template
Icon.ico
VisualBasic
WindowsApp\MyTemplate.vstemplate
ClassLib\MyTemplate.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.

 
 
Multi-Project Template Sample
An example of a multi-project template
Icon.ico
VisualBasic
MathClassLib1\MyTemplate.vstemplate
MathClassLib2\MyTemplate.vstemplate
GraphicsClassLib1\MyTemplate.vstemplate
GraphicsClassLib2\MyTemplate.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

\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:

     
     
  • 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:

     
     
    Project1\Project1.vstemplate
    Project2\Project2.vstemplate

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 .

  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 Documents\Visual Studio Version\Templates\ProjectTemplates\.

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.

 
 
Multi-Project Template Sample
An example of a multi-project template
Icon.ico
VisualBasic
WindowsApp\MyTemplate.vstemplate
ClassLib\MyTemplate.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.

 
 
Multi-Project Template Sample
An example of a multi-project template
Icon.ico
VisualBasic
MathClassLib1\MyTemplate.vstemplate
MathClassLib2\MyTemplate.vstemplate
GraphicsClassLib1\MyTemplate.vstemplate
GraphicsClassLib2\MyTemplate.vstemplate

转载地址:http://sgcmo.baihongyu.com/

你可能感兴趣的文章
电脑蓝屏--代码0x0000008E
查看>>
mysql主从配置(freebsd+mysql5.5.13)
查看>>
开启win7远程桌面
查看>>
使用fir.im和蒲公英进行测试的一些注意事项
查看>>
我的友情链接
查看>>
Yellow dog
查看>>
Python网络编程之协程
查看>>
趣学Python之弹球游戏第二阶段--向上运动
查看>>
过滤全文验证正则表达式的一个小程序
查看>>
Cacti的spine进程数引起的问题
查看>>
我的友情链接
查看>>
求一份oracle数据库实习、兼职的工作
查看>>
storm集群的监控
查看>>
Connector|OIM向IBM TDS推送账号(LDAP3)
查看>>
Linux例行性工作at,cron,进程管理
查看>>
vim批量添加删除注释的方法
查看>>
小成本对付宽带我世界实现有线/无线同时上网
查看>>
QT TableWidget应用笔记
查看>>
yum安装Apache Web Server后各个文件存放位置
查看>>
定制更友好的iptables防火墙
查看>>