You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ide/how-to-create-multi-project-templates.md
+71-45Lines changed: 71 additions & 45 deletions
Original file line number
Diff line number
Diff line change
@@ -22,69 +22,95 @@ ms.workload:
22
22
---
23
23
# How to: Create Multi-Project Templates
24
24
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.
25
+
26
+
A multi-project template is two-or more project templates along with a root template of type `ProjectGroup`.
27
+
28
+
Multi-project templates also behave differently than normal templates. Multi-project templates have the following unique characteristics:
25
29
26
-
A multi-project template must include the following items, compressed into a .zip file:
27
-
28
-
- 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.
29
-
30
-
- 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.
30
+
- 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.
31
31
32
-
For example, a multi-project template .zip file that has two projects could have the following files and directories:
32
+
- 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.
33
33
34
-
MultiProjectTemplate.vstemplate
34
+
### To create a multi-project template
35
35
36
-
\Project1\Project1.vstemplate
36
+
1. Create the projects to include in the multi-project template:
37
+
1. Create a project.
37
38
38
-
\Project1\Project1.vbproj
39
+
> [!NOTE]
40
+
> Use only valid identifier characters when naming a project that will be the source for a template. A template exported from a project named with invalid characters can cause compilation errors in future projects based on the template. For more information on valid identifier characters, see [Declared Element Names](/dotnet/visual-basic/programming-guide/language-features/declared-elements/declared-element-names).
39
41
40
-
\Project1\Class.vb
42
+
2. Edit the project until it is ready to be exported as a template.
41
43
42
-
\Project2\Project2.vstemplate
44
+
3. As appropriate, edit the code files to indicate where parameter replacement should take place. For more information on parameter replacement, see [How to: Substitute Parameters in a Template](../ide/how-to-substitute-parameters-in-a-template.md).
43
45
44
-
\Project2\Project2.vbproj
46
+
4. On the **Project** menu, click **Export Template**. The **Export Template** wizard opens.
45
47
46
-
\Project2\Class.vb
48
+
5. Click **Project Template**.
47
49
48
-
The root .vstemplate file for a multi-project template differs from a single-project template in the following ways:
50
+
6. If you have more than one project in your current solution, select the projects you want to export to a template.
49
51
50
-
-The `Type` attribute of the `VSTemplate` element contains the value `ProjectGroup`. For example:
8. Select an icon and a preview image for your template. These will appear in the **New Project** dialog box.
56
55
57
-
-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:
56
+
9. Enter a template name and description.
58
57
59
-
```
60
-
<TemplateContent>
61
-
<ProjectCollection>
62
-
<ProjectTemplateLink>
63
-
Project1\Project1.vstemplate
64
-
</ProjectTemplateLink>
65
-
<ProjectTemplateLink>
66
-
Project2\Project2.vstemplate
67
-
</ProjectTemplateLink>
68
-
</ProjectCollection>
69
-
</TemplateContent>
70
-
```
71
-
72
-
Multi-project templates also behave differently than normal templates. Multi-project templates have the following unique characteristics:
73
-
74
-
- 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.
75
-
76
-
- 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.
77
-
78
-
### To create a multi-project template
79
-
80
-
1. Create the projects to include in the multi-project template.
81
-
82
-
2. Create .vstemplate files for every project. For more information, see [How to: Create Project Templates](../ide/how-to-create-project-templates.md).
58
+
10. Click **Finish**. Your project is exported into a .zip file and placed in the specified output location, and, if selected, imported into [!INCLUDE[vsprvs](../code-quality/includes/vsprvs_md.md)].
83
59
60
+
2. Extract the .vstemplate file from the generated zip file into the same directory as the project file used to export the template.
61
+
84
62
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.
85
63
86
64
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.
87
65
66
+
> [NOTE!]
67
+
> A multi-project template must include the following items, compressed into a .zip file:
68
+
>
69
+
> - 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.
70
+
>
71
+
> - 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.
72
+
>
73
+
> For example, a multi-project template .zip file that has two projects could have the following files and directories:
74
+
>
75
+
> MultiProjectTemplate.vstemplate
76
+
>
77
+
> \Project1\Project1.vstemplate
78
+
>
79
+
> \Project1\Project1.vbproj
80
+
>
81
+
> \Project1\Class.vb
82
+
>
83
+
> \Project2\Project2.vstemplate
84
+
>
85
+
> \Project2\Project2.vbproj
86
+
>
87
+
> \Project2\Class.vb
88
+
>
89
+
> The root .vstemplate file for a multi-project template differs from a single-project template in the following ways:
90
+
>
91
+
> - 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:
99
+
>
100
+
> ```
101
+
> <TemplateContent>
102
+
> <ProjectCollection>
103
+
> <ProjectTemplateLink>
104
+
> Project1\Project1.vstemplate
105
+
> </ProjectTemplateLink>
106
+
> <ProjectTemplateLink>
107
+
> Project2\Project2.vstemplate
108
+
> </ProjectTemplateLink>
109
+
> </ProjectCollection>
110
+
> </TemplateContent>
111
+
> ```
112
+
>
113
+
88
114
5. Put the .zip template file in the [!INCLUDE[vsprvs](../code-quality/includes/vsprvs_md.md)] project template directory. By default, this directory is \My Documents\Visual Studio *Version*\Templates\ProjectTemplates\\.
89
115
90
116
## Example
@@ -153,4 +179,4 @@ Multi-project templates act as containers for two or more projects. When a proje
153
179
[How to: Create Project Templates](../ide/how-to-create-project-templates.md)
154
180
[Visual Studio Template Schema Reference](../extensibility/visual-studio-template-schema-reference.md)
155
181
[SolutionFolder Element (Visual Studio Templates)](../extensibility/solutionfolder-element-visual-studio-templates.md)
156
-
[ProjectTemplateLink Element (Visual Studio Templates)](../extensibility/projecttemplatelink-element-visual-studio-templates.md)
182
+
[ProjectTemplateLink Element (Visual Studio Templates)](../extensibility/projecttemplatelink-element-visual-studio-templates.md)
0 commit comments