8

I completed the custom template project tutorial part I from msdn and got a basic project structure working and visible in the File - New - Project menu. Then i advanced to msdn part II and can't get past "Testing a Visual Studio Template" part.

When i add the .vstemplate file in the custom project template folder, set the Build Action of all the files under my custom project template folder to ZipProjectand change the 2nd and 6th parameter of the [ProvideProjectFactory] to null and ".\\NullPath"respectively, the File - New - Project doesn't display the custom template in the dialog anymore.

The template zip folder gets placed in the correct folder and i can open the custom projects previously created (this wouldn't work, if the project template wasn't installed), but i can't create any new custom projects as they aren't visible.

Does anybody have experience with creating custom project templates ?

Dante
  • 10,722
  • 16
  • 51
  • 63
  • in walk through it says 3.Replace the fourth parameter (the path to the project template folder) by using ".\\NullPath"----- but you changed 6th parameter to ".\\NullPath" – Civa Mar 30 '13 at 05:18
  • 1
    @Civa Because it is the 6th parameter, there is a typo in the sentence. – Dante Mar 30 '13 at 05:20
  • See if this helps in anyway, http://stackoverflow.com/questions/3941943/visual-studio-2010-project-template-doesnt-show-up – Joban Apr 06 '13 at 00:27

1 Answers1

2

When creating a Visual Studio 2012 extension, you can actually create a separate project for each project template you'd like to ship. The template for creating these projects is located at the following path in the New Project wizard. You'll need one project for each template you are creating.

Visual C# → Extensibility → C# Project Template

Your main extension project (the one that produces the VSIX file) will then need to do the following:

  1. Add a reference to the project for your new project template
  2. Select the reference and press F4 to jump to the Properties window. Make sure the following properties are set.
    • Output Groups Included in VSIX: TemplateProjectOutputGroup;
    • Template Type: Project
    • VSIX Sub Path: ProjectTemplates
    • Reference Output Assembly: False
  3. Open your source.extension.vsixmanifest and add the following under <Content> (You only need this once, regardless of the number of project templates are referencing.)
    • <ProjectTemplate>ProjectTemplates</ProjectTemplate>
  4. Change the 6th argument of [ProvideProjectFactory(... to "ProjectTemplates".

Notes:

  • After this process, you will no longer have a Templates folder in your main project.
Sam Harwell
  • 97,721
  • 20
  • 209
  • 280
  • Following your suggestion, I notice (in VS2013 at least) that the `.vstemplate` file has a build action of `VSTemplate` - something that was not mentioned in the original MSDN walkthrough. Is this one of the reasons why it works now? Thanks –  Jan 07 '15 at 08:15