Monday, July 15, 2013

Adding a Project Template to a VS Isolated Shell Application

I’ve recently spent way too much time trying to figure out why a VS Project Template I created by following the Creating a Basic Project System walkthrough wasn’t showing up on the New Project dialog of my VS Isolated Shell application. Turns out the build process wasn’t putting my template archive where the application was looking for it.

I created my application by using the Visual Studio Shell Isolated project template in VS2012, this generated four projects. Then I went ahead and added a new Visual Studio Package project (called DylanProject in this case) as per the walkthrough.

Solution Explorer

By default the ShellExtensionsVSIX project is configured to copy VSIX content to the location where the isolated shell application looks for extensions. So, I assumed that all I had to do after adding my project template to the new VSPackage was to update the source.extension.vsixmanifest in the ShellExtensionsVSIX project to include the new VSPackage.

ShellExtensionsVSIX Configuration

Unfortunately the extensions directory isn’t where the isolated shell application looks for templates, instead it looks in the locations specified in the .Application.pkgdef file in the application project (in my case DylanVSShell). Here’s the relevant excerpt from my DylanVSShell.Application.pkgdef:

// Create local VS template location
[$RootKey$\VSTemplate\Item]
"UserFolder"="$RootFolder$\ItemTemplates"
"CacheFolder"="$RootFolder$\ItemTemplatesCache"

[$RootKey$\VSTemplate\Project]
"UserFolder"="$RootFolder$\ProjectTemplates"
"CacheFolder"="$RootFolder$\ProjectTemplatesCache"

Where $RootFolder$ refers to the location where the isolated shell application executable resides. To ensure the templates end up in the correct location I’ve added a post build event to the VSPackage to copy the template archives, like so:

xcopy /I /Y /F $(TargetDir)ProjectTemplates\*.zip  $(SolutionDir)$(ConfigurationName)\ProjectTemplates

Might need to adjust those xcopy flags slightly to handle subdirectories in the ProjectTemplates directory if need be.

1 comment:

fabi said...

Hello, first of all, sorry for my english.

I use VS2010 for create templates but don't appears in shell isolated, however appears in Visual Studio.

I don't know if I could explain well, but any questions or assistance would serve me.

Thank you very much.
Fabiana.