Skip to content

Commit 1c05b3d

Browse files
committed
docs(templates): document auto-inject Content feature
1 parent 9349140 commit 1c05b3d

1 file changed

Lines changed: 35 additions & 15 deletions

File tree

docs/templates.md

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ This SDK handles template packaging by:
1717

1818
1. **Auto-discovering** templates in `ProjectTemplates/` and `ItemTemplates/` folders
1919
2. **Including template files** in the VSIX package automatically
20-
3. **Supporting cross-project template references** for including templates from other SDK-style projects
21-
4. **Providing validation warnings** if your manifest is missing required Content entries
20+
3. **Auto-injecting manifest Content entries** so you don't need to manually edit the manifest
21+
4. **Supporting cross-project template references** for including templates from other SDK-style projects
2222

23-
Your manifest must contain `<Content><ProjectTemplate/></Content>` entries for Visual Studio to register and display templates. The SDK includes the template files in the VSIX; the manifest entries tell VS how to find and register them.
23+
Visual Studio requires `<Content><ProjectTemplate/></Content>` entries in the manifest to register and display templates. The SDK automatically injects these entries when templates are discovered, so you don't need to add them manually.
2424

2525
## Item Types
2626

@@ -56,12 +56,10 @@ MyExtension/
5656
MyClass.cs
5757
```
5858

59-
With this structure, minimal configuration is needed. The SDK will:
59+
With this structure, no additional configuration is needed. The SDK will:
6060
1. Find the templates automatically
6161
2. Include all template files in the VSIX
62-
3. Warn if `<Content>` entries are missing from the manifest
63-
64-
You need to add the Content entries to your manifest manually (see Manifest Configuration below).
62+
3. Inject the required `<Content>` entries into the manifest automatically
6563

6664
### Disabling Auto-Discovery
6765

@@ -104,7 +102,29 @@ The `TemplatePath` is relative to the referenced project's directory.
104102

105103
## Manifest Configuration
106104

107-
Visual Studio requires `<Content>` entries in your `.vsixmanifest` to register templates. Add these to your manifest:
105+
Visual Studio requires `<Content>` entries in your `.vsixmanifest` to register templates. **The SDK automatically injects these entries** when templates are discovered, so you typically don't need to add them manually.
106+
107+
### Automatic Content Injection (Default)
108+
109+
When `AutoInjectVsixTemplateContent` is enabled (the default), the SDK:
110+
1. Creates an intermediate manifest in the `obj` folder
111+
2. Injects `<ProjectTemplate Path="ProjectTemplates"/>` if project templates are discovered
112+
3. Injects `<ItemTemplate Path="ItemTemplates"/>` if item templates are discovered
113+
4. Uses the intermediate manifest for VSIX packaging (your source manifest is never modified)
114+
115+
This means your source `.vsixmanifest` does not need a `<Content>` section at all when using templates.
116+
117+
### Disabling Auto-Injection
118+
119+
If you prefer to manage the manifest Content entries manually, disable auto-injection:
120+
121+
```xml
122+
<PropertyGroup>
123+
<AutoInjectVsixTemplateContent>false</AutoInjectVsixTemplateContent>
124+
</PropertyGroup>
125+
```
126+
127+
When auto-injection is disabled, you must add the Content entries to your manifest manually:
108128

109129
```xml
110130
<Content>
@@ -117,6 +137,8 @@ The SDK will emit warnings if you have templates but missing manifest entries:
117137
- **VSIXSDK011**: Project templates defined but no `<ProjectTemplate>` in manifest
118138
- **VSIXSDK012**: Item templates defined but no `<ItemTemplate>` in manifest
119139

140+
These warnings only appear when `AutoInjectVsixTemplateContent` is set to `false`.
141+
120142
## Complete Example
121143

122144
### Project File
@@ -142,7 +164,7 @@ The SDK will emit warnings if you have templates but missing manifest entries:
142164

143165
### Manifest File
144166

145-
Add the `<Content>` entries for your templates:
167+
The SDK automatically injects Content entries, so your manifest doesn't need them:
146168

147169
```xml
148170
<?xml version="1.0" encoding="utf-8"?>
@@ -157,10 +179,7 @@ Add the `<Content>` entries for your templates:
157179
<ProductArchitecture>amd64</ProductArchitecture>
158180
</InstallationTarget>
159181
</Installation>
160-
<Content>
161-
<ProjectTemplate Path="ProjectTemplates" />
162-
<ItemTemplate Path="ItemTemplates" />
163-
</Content>
182+
<!-- Content entries are auto-injected by the SDK -->
164183
</PackageManifest>
165184
```
166185

@@ -198,10 +217,11 @@ Add the `<Content>` entries for your templates:
198217

199218
### Templates not appearing in Visual Studio
200219

201-
1. Ensure your manifest has the appropriate `<Content>` entries
202-
2. Check that the template folders are included in the VSIX (open the .vsix as a zip)
220+
1. Check that the template folders are included in the VSIX (open the .vsix as a zip)
221+
2. Verify the intermediate manifest (`obj/*/source.extension.vsixmanifest`) contains the `<Content>` entries
203222
3. Verify the `.vstemplate` file has correct `<ProjectType>` or `<TemplateGroupID>`
204223
4. Reset the Visual Studio template cache: delete `%LocalAppData%\Microsoft\VisualStudio\<version>\ComponentModelCache`
224+
5. If using `AutoInjectVsixTemplateContent=false`, ensure your source manifest has the `<Content>` entries
205225

206226
### Build errors about missing template folders
207227

0 commit comments

Comments
 (0)