locked
Customized Project Template copied into Project Templates folder but not showing up in New Project dialog RRS feed

  • Question

  • I need to change an exported project template based on answer to this thread: http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/19b83b82-821b-4eb8-bd7a-23f09b290f86/

    However, when I make these changes and recreate the .zip file, the template no longer shows up in my New Project dialog.  I've played around with it a bit to try to isolate the behavior.

    First of all, it may or may not be significant that my (Tools -> Options -> Projects and Solutions) User project templates location is set to a shared folder on a file server (\\myshare\VisualStudio\Templates\ProjectTemplates), not a local folder on my computer.

    I've exported WCFService template, which then exists in two folders: project templates folder, and My Exported Templates folder.  The project templates folder seems to be the significant one, since when I delete a template from there, that template no longer appears in my New Project dialog.  I can even delete a template from there, and then copy it back there from My Exported Templates, and it will show up again in the New Project dialog.  But if I place a brand new .zip file in that project templates folder, that template does not show up in my New Project dialog.  I can also copy an existing template from My Exported Templates and rename it and place that in the project templates folder, and an extra entry for that template will show up, so I know it's not based on the name of the .zip file, but rather the contents of the vstemplates file.

    However, I am not able to get a newly created .zip file to show up in my New Projects dialog.

    Here is the MyTemplate.vstemplate file:

    <VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
     <TemplateData>
      <Name>WCFServiceTest</Name>
      <Description>&lt;No description available&gt;</Description>
      <ProjectType>CSharp</ProjectType>
      <ProjectSubType>
      </ProjectSubType>
      <SortOrder>1000</SortOrder>
      <CreateNewFolder>true</CreateNewFolder>
      <DefaultName>WCFServiceTest</DefaultName>
      <ProvideDefaultName>true</ProvideDefaultName>
      <LocationField>Enabled</LocationField>
      <EnableLocationBrowseButton>true</EnableLocationBrowseButton>
      <Icon>__TemplateIcon.ico</Icon>
     </TemplateData>
     <TemplateContent>
      <Project TargetFileName="WCFServiceTest.csproj" File="WCFServiceTest.csproj" ReplaceParameters="true">
       <Folder Name="App_Data" TargetFolderName="App_Data" />
       <ProjectItem ReplaceParameters="true" TargetFileName="IService1.cs">IService1.cs</ProjectItem>
       <Folder Name="Properties" TargetFolderName="Properties">
        <ProjectItem ReplaceParameters="true" TargetFileName="AssemblyInfo.cs">AssemblyInfo.cs</ProjectItem>
       </Folder>
       <ProjectItem ReplaceParameters="true" TargetFileName="Service1.svc">Service1.svc</ProjectItem>
       <ProjectItem ReplaceParameters="true" TargetFileName="Service1.svc.cs">Service1.svc.cs</ProjectItem>
       <ProjectItem ReplaceParameters="true" TargetFileName="Web.config">Web.config</ProjectItem>
       <ProjectItem ReplaceParameters="true" TargetFileName="Web.Debug.config">Web.Debug.config</ProjectItem>
       <ProjectItem ReplaceParameters="true" TargetFileName="Web.Release.config">Web.Release.config</ProjectItem>
      </Project>
     </TemplateContent>
    </VSTemplate>
    

    I would expect that to make a a template named WCFServiceTest show up in my New Projects dialog.

    I have also tried making the minimal modifications referenced in the link above, with my MyTemplate.vstemplate looking like this:

    <VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
     <TemplateData>
      <Name>WCFService</Name>
      <Description>&lt;No description available&gt;</Description>
      <ProjectType>CSharp</ProjectType>
      <ProjectSubType>
      </ProjectSubType>
      <SortOrder>1000</SortOrder>
      <CreateNewFolder>true</CreateNewFolder>
      <DefaultName>WCFService</DefaultName>
      <ProvideDefaultName>true</ProvideDefaultName>
      <LocationField>Enabled</LocationField>
      <EnableLocationBrowseButton>true</EnableLocationBrowseButton>
      <Icon>__TemplateIcon.ico</Icon>
     </TemplateData>
     <TemplateContent>
      <Project TargetFileName="WCFService.csproj" File="WCFService.csproj" ReplaceParameters="true">
       <Folder Name="App_Data" TargetFolderName="App_Data" />
       <ProjectItem ReplaceParameters="true" TargetFileName="IService1.cs">IService1.cs</ProjectItem>
       <Folder Name="Properties" TargetFolderName="Properties">
        <ProjectItem ReplaceParameters="true" TargetFileName="AssemblyInfo.cs">AssemblyInfo.cs</ProjectItem>
       </Folder>
       <ProjectItem ReplaceParameters="true" TargetFileName="Service1.svc">Service1.svc</ProjectItem>
       <ProjectItem ReplaceParameters="true" TargetFileName="Service1.svc.cs">Service1.svc.cs</ProjectItem>
       <ProjectItem ReplaceParameters="true" TargetFileName="Web.config">Web.config</ProjectItem>
       <ProjectItem ReplaceParameters="true" TargetFileName="Web.Debug.config">Web.Debug.config</ProjectItem>
       <ProjectItem ReplaceParameters="true" TargetFileName="Web.Release.config">Web.Release.config</ProjectItem>
      </Project>
     </TemplateContent>
    </VSTemplate>
    

    I am using Visual Studio 2010 Professional, with TFS if that matters.

     

    Can anyone help me understand what I'm doing wrong?  I get the impression I should be able to simply create a .zip file and drop it in my project templates folder and be done with it, but I'm not able to make that happen.

    Thanks

     

    Monday, August 1, 2011 1:03 PM

Answers

  • Hi Matt,

    You are right in that ProjectTemplates folder is the important one here as the other "My Exported Templates" folder is just for your use and Visual Studio will not look in to there. However if you are just decompressing an existing template file, changing the vstemplate and rezipping everything in the same structure, there shouldn't be any reason the new template doesn't work.

    Could you verify whether vstemplate file exists in the root folder of the zip file? Also what do you use to create the zip file, one thing to try would be to see if it works if you just decompress the files and zip them again and use that new zip file?

    Regards,

    Bertan Aygun

    • Marked as answer by Matt Knowles Tuesday, August 2, 2011 12:06 PM
    Tuesday, August 2, 2011 2:11 AM

All replies

  • Hi Matt,

    You are right in that ProjectTemplates folder is the important one here as the other "My Exported Templates" folder is just for your use and Visual Studio will not look in to there. However if you are just decompressing an existing template file, changing the vstemplate and rezipping everything in the same structure, there shouldn't be any reason the new template doesn't work.

    Could you verify whether vstemplate file exists in the root folder of the zip file? Also what do you use to create the zip file, one thing to try would be to see if it works if you just decompress the files and zip them again and use that new zip file?

    Regards,

    Bertan Aygun

    • Marked as answer by Matt Knowles Tuesday, August 2, 2011 12:06 PM
    Tuesday, August 2, 2011 2:11 AM
  • Hi Bertan, thanks for the reply.  I was wondering all day yesterday if I really should have posted a detailed step-by-step for this, so I'll go ahead and do that now.

     

    1. Start Visual Studio 2010 Professional.

    2. Create a new Project from the built-in WCF Service Application template.

    3. Export a project template, in my case WcfService4.

    4. Close and re-open Visual Studio to verify that WcfService4 project template appears in New Project dialog: it does.

    4. Extract <projectTemplatesFolder>/WcfService4.zip to <projectTemplatesFolder>/WcfService4 using built-in Windows 7 right-click -> Extract All with default options.

    5. Delete <projectTemplatesFolder>/WcfService4.zip.

    6. Zip <projectTemplatesFolder>/WcfService4folder to <projectTemplatesFolder>/WcfService4.zip using built-in Windows 7 right-click -> Send To -> Compressed (zipped) Folder with default options.

    7. Close and re-open Visual Studio to verify that WcfService4 project template appears in New Project dialog: it does **NOT**.

    8. Delete <projectTemplatesFolder>/WcfService4.zip.

    9. Copy <MyExportedTemplates>/WcfService4.zip to <projectTemplatesFolder>

    10. Close and re-open Visual Studio to verify that WcfService4 project template appears in New Project dialog: it does.

     

    Is there something about the built-in Send To -> Compressed (zipped) Folder that is causing my problems?

     

    Tuesday, August 2, 2011 12:03 PM
  • Bingo!

    After posting my step-by-step, I re-read your questions to make sure I had answered them all.  I realized I hadn't with respect to making sure the vstemplate file was in the root folder of the .zip.  As you might have guessed, it was not.

    I was zipping the WcfService4 folder, rather than zipping that folder's contents.  Once I did that, it worked fine.

    Thanks again for your help!

     

    Tuesday, August 2, 2011 12:06 PM