0

I'm creating a new project template as a Visual Studio extension project and want it to be displayed in my custom group, that does exist before project template is installed, under Visual C# node.

enter image description here

I was hoping it is possible to setup project template location in it's .vstemplate file TemplateData section. I've tried to set ProjectSubType value, TemplateGroupID, NumberOfParentCategoriesToRollUp but it doesn't work. When Experimental instance of visual studio starts the project template is always in Visual C# group but not in Visual C#/My Group. ProjectSubType doesn't work even if My Group already exists but the documentation says it should be created in subgroup. How can I set project template location in TemplateData section?

Dmytro
  • 16,668
  • 27
  • 80
  • 130

1 Answers1

1

Custom templates do not include a subdirectory for localized templates. You can change the default directory for custom templates in the Options dialog box, under Environment\Projects and Solutions.

I often add a folder manually and then copy the zip file, for example, I create a folder called "My Group" under the folder C:\Users\xxx\Documents\Visual Studio 2017\Templates\ProjectTemplates\Visual C#.

And then create a simple Console app called Jack and export this project template, I didn't select this option. enter image description here

Then I copy the Jack.zip to the above My Group folder. Re-open the VS, I will get this project template under the My Group folder.

enter image description here

This is the default .vstemplate file in my side:

    <VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
  <TemplateData>
    <Name>Jack</Name>
    <Description>&lt;No description available&gt;</Description>
    <ProjectType>CSharp</ProjectType>
    <ProjectSubType>
    </ProjectSubType>
    <SortOrder>1000</SortOrder>
    <CreateNewFolder>true</CreateNewFolder>
    <DefaultName>Jack</DefaultName>
    <ProvideDefaultName>true</ProvideDefaultName>
    <LocationField>Enabled</LocationField>
    <EnableLocationBrowseButton>true</EnableLocationBrowseButton>
    <Icon>__TemplateIcon.ico</Icon>
  </TemplateData>
  <TemplateContent>
    <Project TargetFileName="Jack.csproj" File="Jack.csproj" ReplaceParameters="true">
      <ProjectItem ReplaceParameters="true" TargetFileName="App.config">App.config</ProjectItem>
      <ProjectItem ReplaceParameters="true" TargetFileName="Program.cs">Program.cs</ProjectItem>
      <Folder Name="Properties" TargetFolderName="Properties">
        <ProjectItem ReplaceParameters="true" TargetFileName="AssemblyInfo.cs">AssemblyInfo.cs</ProjectItem>
      </Folder>
    </Project>
  </TemplateContent>
</VSTemplate>
Fletcher
  • 422
  • 1
  • 6
  • 21
  • Thanks for your answer, but I don't want to manually copy installed template. I export my template as a Visual Studio extension. And after I build VSIX file and install my extension I want my template to be in place without any manual manipulations. – Dmytro Mar 16 '18 at 09:55
  • If so, can it create the new folder "My Group" in the default project template folder? Can it copy the zip file to the created folder in your VSIX project? – Jack Zhai Mar 19 '18 at 09:25
  • So what you are suggesting is to create folder and copy installed .zip template file with C# code? Is it considered a good practice? Aren't there some built in methods? And if so ... Where should I handle this "Installation Completed" event? – Dmytro Mar 21 '18 at 10:58