如何在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
\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">
- <VSTemplate Version="2.0.0" Type="ProjectGroup"
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>
- Project1\Project1.vstemplate
- </ProjectTemplateLink>
- <ProjectTemplateLink>
- Project2\Project2.vstemplate
- </ProjectTemplateLink>
- </ProjectCollection>
- </TemplateContent>
- <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
Create the projects to include in the multi-project template.
Create .vstemplate files for every project. For more information, see How to: Create Project Templates.
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.
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.
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.
- <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 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">
- MathClassLib1\MyTemplate.vstemplate
- </ProjectTemplateLink>
- <ProjectTemplateLink ProjectName="MathClassLib2">
- MathClassLib2\MyTemplate.vstemplate
- </ProjectTemplateLink>
- </SolutionFolder>
- <SolutionFolder Name="Graphics Classes">
- <ProjectTemplateLink ProjectName="GraphicsClassLib1">
- GraphicsClassLib1\MyTemplate.vstemplate
- </ProjectTemplateLink>
- <ProjectTemplateLink ProjectName="GraphicsClassLib2">
- GraphicsClassLib2\MyTemplate.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
\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">
- <VSTemplate Version="2.0.0" Type="ProjectGroup"
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>
- Project1\Project1.vstemplate
- </ProjectTemplateLink>
- <ProjectTemplateLink>
- Project2\Project2.vstemplate
- </ProjectTemplateLink>
- </ProjectCollection>
- </TemplateContent>
- <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
Create the projects to include in the multi-project template.
Create .vstemplate files for every project. For more information, see How to: Create Project Templates.
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.
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.
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.
- <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 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">
- MathClassLib1\MyTemplate.vstemplate
- </ProjectTemplateLink>
- <ProjectTemplateLink ProjectName="MathClassLib2">
- MathClassLib2\MyTemplate.vstemplate
- </ProjectTemplateLink>
- </SolutionFolder>
- <SolutionFolder Name="Graphics Classes">
- <ProjectTemplateLink ProjectName="GraphicsClassLib1">
- GraphicsClassLib1\MyTemplate.vstemplate
- </ProjectTemplateLink>
- <ProjectTemplateLink ProjectName="GraphicsClassLib2">
- GraphicsClassLib2\MyTemplate.vstemplate
- </ProjectTemplateLink>
- </SolutionFolder>
- </ProjectCollection>
- </TemplateContent>
- </VSTemplate>
如何在Visual Studio VS中定义多项目模板的更多相关文章
- 如何在Visual Studio 2017中使用C# 7+语法 构建NetCore应用框架之实战篇(二):BitAdminCore框架定位及架构 构建NetCore应用框架之实战篇系列 构建NetCore应用框架之实战篇(一):什么是框架,如何设计一个框架 NetCore入门篇:(十二)在IIS中部署Net Core程序
如何在Visual Studio 2017中使用C# 7+语法 前言 之前不知看过哪位前辈的博文有点印象C# 7控制台开始支持执行异步方法,然后闲来无事,搞着,搞着没搞出来,然后就写了这篇博文,不 ...
- 如何在"Visual Studio Code"中使用" Git" 进行版本控制
如何在"Visual Studio Code"中使用" Git" 进行版本控制 本来认为此类教程,肯定是满网飞了.今天首次使用VS Code的Git功能,翻遍了 ...
- 如何在Visual Studio 2012中发布Web应用程序时自动混淆Javascript
同Java..NET实现的应用程序类似,Javascript编写的应用程序也面临一个同样的问题:源代码的保护.尽管对大多数Javascript应用公开源代码不算是很严重的问题,但是对于某些开发者来说, ...
- 如何在Visual Studio 2013中使用Ribbon For WPF
1.首先需要 下载Ribbon For WPF.目前最新的版本是Microsoft Ribbon for WPF October 2010. 下载 链接: https://www.microsoft. ...
- 如何在Visual Studio 2017中使用C# 7+语法
前言 之前不知看过哪位前辈的博文有点印象C# 7控制台开始支持执行异步方法,然后闲来无事,搞着,搞着没搞出来,然后就写了这篇博文,不喜勿喷,或许对您有帮助. 在Visual Studio 2017配置 ...
- 如何在Visual Studio 2013中连接中国版的Azure
http://diaosbook.com/Post/2014/8/23/connect-azure-cn-in-vs2013 VS2013的Server Explorer在第一次连接Azure的时 ...
- Visual Studio 2013中的新项目对话框
在Visual Studio 2013,我们推出了添加新的项目对话框. 此对话框取代了是曾在2012年这个的对话框作品,所有ASP.NET项目(MVC,Web窗体和Web API). 这就是我们如何提 ...
- SharpDX初学者教程第1部分:在Visual Studio 2013中设置SharpDX项目
原文 http://www.johanfalk.eu/blog/sharpdx-tutorial-part-1-setting-up-a-sharpdx-project-in-visual-studi ...
- 如何在 Visual Studio 2013 中调试.NET Framework 4.5.1 代码
版本需求如标题,在 工具->选项->调试->常规 中,更改以下设置: 禁用:启用“仅我的代码”.逐过程执行属性和运算符(仅限托管).要求源文件与原始版本完全匹配 启用:启用 .NET ...
随机推荐
- Oracle Data Integrator 12c-第一个映射
一.创建"项目" 设计器->项目,点击插入项目图标, 在项目对话框的"定义"标签下输入项目名称如ODI_Exercise ,保存 二.导入知识模块 项目→ ...
- 【DB2】索引
1. 索引的概念 1.1 索引的优点 索引是表的一个或多个列的键值的有序列表,创建索引的原因有2个: 确保一个或多个列中值的唯一性 提高对表进行的查询的性能.当查询时想要以更快的速度找到所需要的列,或 ...
- JAVA中的CountDownLatch、CyclicBarrier、Semaphore的简单测试
因公司需要做一个对于CountDownLatch的分享,特写了此blog. 具体细节可以参见:小结java自带的跟锁相关的一些类 在做这个分享的过程中发现了Main和junit的运行的区别,在另外一个 ...
- Qt Installer Framework 使用说明(一)
目录 Qt Installer Framework 使用说明 1.Qt Installer Framework概述 选择安装包类型 促进更新 提供安装内容 2.入门指南 支持的平台 从源代码构建 支持 ...
- codevs 2010 求后序遍历
时间限制: 1 s空间限制: 64000 KB题目描述 Description输入一棵二叉树的先序和中序遍历序列,输出其后序遍历序列.输入描述 Input Description共两行,第一行一个字符 ...
- RHEL6.5 grub修复测试
RHEL6.5 grub修复测试 1.删除系统中的grub.conf配置文件,然后重启系统#rm -f /boot/grub/grub.conf#reboot 2.重启后,系统进入到grub界面:gr ...
- weblogic部署存在中文乱码导致部署失败
问题描述: weblogic控制台显示错误,是受管节点console日志 <-- 下午10时19分16秒 CST> <Info> <Security> <BE ...
- 基于RecyclerView实现的分组显示信息demo
发布时间:2018-11-07 技术:Android Studio 3.1.3+ RecyclerView+sectionRecyclerViewAdapter 概述 利用sectionedR ...
- ios真机调试步骤
http://blog.csdn.net/jianxuanlu/article/details/7283059 http://www.cnblogs.com/85538649/archive/2012 ...
- Delphi单元文件引用名称问题
Delphi新版本的单元文件格式变化了,如windows变成了winapi.windows,如果想在单元引用中使用简称,则需要在工程选项中配置: 这样就可以使用全名或简写来引用单元了.