This document explains how to include Visual Studio project templates and item templates in your VSIX extension using CodingWithCalvin.VsixSdk.
The built-in VSIX Manifest Designer in Visual Studio cannot enumerate SDK-style projects when adding template assets. This is because the designer uses legacy DTE extenders that are registered for the old project system, not the Common Project System (CPS) used by SDK-style projects.
This SDK provides MSBuild-based template support that works around these limitations by:
- Auto-discovering templates in standard folders
- Supporting cross-project template references
- Providing validation warnings for missing manifest Content entries
This SDK handles template packaging by:
- Auto-discovering templates in
ProjectTemplates/andItemTemplates/folders - Including template files in the VSIX package automatically
- Supporting cross-project template references for including templates from other SDK-style projects
- Providing validation warnings if your manifest is missing required Content entries
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.
The SDK provides the following item types for templates:
| Item Type | Description |
|---|---|
VsixProjectTemplate |
(Auto-discovered) A folder containing a .vstemplate file for a project template |
VsixItemTemplate |
(Auto-discovered) A folder containing a .vstemplate file for an item template |
VsixTemplateReference |
Reference a template folder from another project |
By default, the SDK automatically discovers templates in your project:
- Project templates: Any subfolder in
ProjectTemplates/containing a.vstemplatefile - Item templates: Any subfolder in
ItemTemplates/containing a.vstemplatefile
MyExtension/
MyExtension.csproj
source.extension.vsixmanifest
ProjectTemplates/
MyProjectTemplate/
MyProjectTemplate.vstemplate
MyProject.csproj
Class1.cs
ItemTemplates/
MyItemTemplate/
MyItemTemplate.vstemplate
MyClass.cs
With this structure, minimal configuration is needed. The SDK will:
- Find the templates automatically
- Include all template files in the VSIX
- Warn if
<Content>entries are missing from the manifest
You need to add the Content entries to your manifest manually (see Manifest Configuration below).
To disable automatic template discovery:
<PropertyGroup>
<EnableDefaultVsixTemplateItems>false</EnableDefaultVsixTemplateItems>
</PropertyGroup>To use different folder names:
<PropertyGroup>
<VsixProjectTemplatesFolder>Templates\Projects</VsixProjectTemplatesFolder>
<VsixItemTemplatesFolder>Templates\Items</VsixItemTemplatesFolder>
</PropertyGroup>When you have templates in a separate SDK-style project that the VSIX Manifest Designer cannot enumerate, use VsixTemplateReference:
<ItemGroup>
<VsixTemplateReference Include="..\MyTemplateProject\MyTemplateProject.csproj"
TemplateType="Project"
TemplatePath="Templates\MyProjectTemplate" />
</ItemGroup>The SDK will:
- Copy the template folder from the referenced project to your local
ProjectTemplates/orItemTemplates/folder - Include the copied template files in the VSIX
The TemplatePath is relative to the referenced project's directory.
Visual Studio requires <Content> entries in your .vsixmanifest to register templates. Add these to your manifest:
<Content>
<ProjectTemplate Path="ProjectTemplates" />
<ItemTemplate Path="ItemTemplates" />
</Content>The SDK will emit warnings if you have templates but missing manifest entries:
- VSIXSDK011: Project templates defined but no
<ProjectTemplate>in manifest - VSIXSDK012: Item templates defined but no
<ItemTemplate>in manifest
<Project Sdk="CodingWithCalvin.VsixSdk/1.0.0">
<PropertyGroup>
<Version>1.0.0</Version>
</PropertyGroup>
<!-- Templates in ProjectTemplates/ and ItemTemplates/ are auto-discovered -->
<!-- Include templates from another SDK-style project -->
<ItemGroup>
<VsixTemplateReference Include="..\SharedTemplates\SharedTemplates.csproj"
TemplateType="Project"
TemplatePath="Templates\SharedProject" />
</ItemGroup>
</Project>Add the <Content> entries for your templates:
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011">
<Metadata>
<Identity Id="MyExtension" Version="1.0.0" Language="en-US" Publisher="MyCompany" />
<DisplayName>My Extension</DisplayName>
<Description>Extension with templates</Description>
</Metadata>
<Installation>
<InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[17.0,19.0)">
<ProductArchitecture>amd64</ProductArchitecture>
</InstallationTarget>
</Installation>
<Content>
<ProjectTemplate Path="ProjectTemplates" />
<ItemTemplate Path="ItemTemplates" />
</Content>
</PackageManifest><?xml version="1.0" encoding="utf-8"?>
<VSTemplate Version="3.0.0" Type="Project" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005">
<TemplateData>
<Name>My Project Template</Name>
<Description>A sample project template</Description>
<Icon>__TemplateIcon.ico</Icon>
<ProjectType>CSharp</ProjectType>
<DefaultName>MyProject</DefaultName>
<ProvideDefaultName>true</ProvideDefaultName>
</TemplateData>
<TemplateContent>
<Project File="MyProject.csproj" ReplaceParameters="true">
<ProjectItem ReplaceParameters="true">Class1.cs</ProjectItem>
</Project>
</TemplateContent>
</VSTemplate>| Code | Description |
|---|---|
| VSIXSDK011 | Project templates defined but no <ProjectTemplate> in manifest |
| VSIXSDK012 | Item templates defined but no <ItemTemplate> in manifest |
| VSIXSDK013 | VsixTemplateReference item missing TemplateType metadata |
| VSIXSDK014 | VsixTemplateReference item missing TemplatePath metadata |
- Ensure your manifest has the appropriate
<Content>entries - Check that the template folders are included in the VSIX (open the .vsix as a zip)
- Verify the
.vstemplatefile has correct<ProjectType>or<TemplateGroupID> - Reset the Visual Studio template cache: delete
%LocalAppData%\Microsoft\VisualStudio\<version>\ComponentModelCache
Ensure the template folder exists and contains a .vstemplate file. For VsixTemplateReference, verify the TemplatePath is correct relative to the referenced project.
- Verify the referenced project path is correct
- Check that
TemplateTypeis set toProjectorItem - Ensure
TemplatePathpoints to a folder containing a.vstemplatefile - The template folder will be copied to your local
ProjectTemplates/orItemTemplates/folder during build