locked
Custom project templates does not show up again if you delete any. RRS feed

  • Question

  • I made a simple C# project template for Visual Studio, referring to the following sites.

    • https://docs.microsoft.com/ja-jp/visualstudio/ide/creating-project-and-item-templates?view=vs-2019
    • https://docs.microsoft.com/ja-jp/visualstudio/ide/how-to-create-project-templates?view=vs-2019

    This works well, and in the 'Create a new project Dialog' Window, I can search by project name, and when selected, it creates a project and solution based on the template.

    The name of this template is 'SimpleTemplate'. I confirmed that the following files were generated by the template export process.

    • C:\Users\[UserName]\Documents\Visual Studio 2019\Templates\ProjectTemplates\SimpleTemplate.zip

    I deleted the zip file and repeated the process again to reconfirm this step.
    To be specific I deleted the project once, and recreated from begning, and then exported exactly the same way I did it in a few menutes before.

    Then I found that, for some reason, Visual Studio is not be able to load my custom project templates after that.
    So I created a SimpleTempate2 or SimpleTemplate3, trying to let Visual Studio recognize the new custom template is prepared, but that did not work at all.
    Any of custom project template doesn't show up at all when I try to select a tag, even if I enter a keyword in the Create a new project Dialog.

    If you are interested, please give it a try. Is this only occurring in my environment, or it is happening in other environments?

    The super-simple project template I created to try out is located below.

    https://github.com/TrailRunner-MF/Samples/tree/master/SimpleProjectTemplate

    My environment is as follows.

    • Processor: Intel(R) Core(TM) i5-24005 CPU @2.50GHz
    • Implemented memory: 16.0GM
    • System type: 64-bit operating system
    • Windows editions: Windows 10 Enterprise
    • Microsoft Visual Studio Professional 2019 Version 16.5.2

    If you have any information on how to solve this problem, please share it with us.

    Thank you.









    Monday, April 6, 2020 10:54 AM

Answers

  • Hi TrialRunner-MF,

    Welcome to MSDN forum.

    I download your sample on github, and copy "...\Samples-master\Samples-master\SimpleProjectTemplate.zip" to "C:\Users\[UserName]\Documents\Visual Studio 2019\Templates\ProjectTemplates\", my vs can't recognize it either. But my other custom templates can work normally.

    After checking your zip file, please modify your template following these points:

    1. Remove sub-directory, such as delete "Properties" folder and place all files together
    2. VS will only load one vstemplate file, and if two or more occur, vs will automatically retain one. To avoid data loss or unknown errors, we recommend keeping only one vstemplate file in your template.                                                                                         
    3. Don't use macro values to name project template. For example, please change "$safeprojectname$" to "SimpleProjectTemplate".        

    After these, your vs will recognize your template normally.

    Any feedback will be expected.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Tuesday, April 7, 2020 6:42 AM

All replies

  • Hi TrialRunner-MF,

    Welcome to MSDN forum.

    I download your sample on github, and copy "...\Samples-master\Samples-master\SimpleProjectTemplate.zip" to "C:\Users\[UserName]\Documents\Visual Studio 2019\Templates\ProjectTemplates\", my vs can't recognize it either. But my other custom templates can work normally.

    After checking your zip file, please modify your template following these points:

    1. Remove sub-directory, such as delete "Properties" folder and place all files together
    2. VS will only load one vstemplate file, and if two or more occur, vs will automatically retain one. To avoid data loss or unknown errors, we recommend keeping only one vstemplate file in your template.                                                                                         
    3. Don't use macro values to name project template. For example, please change "$safeprojectname$" to "SimpleProjectTemplate".        

    After these, your vs will recognize your template normally.

    Any feedback will be expected.

    Best Regards,

    Dylan


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Tuesday, April 7, 2020 6:42 AM
  • Hi, Dylan. Thank you for your guidance.
    I worked according to your instructions and everything went well.

    I deleted the file you pointed out as redundant, include 'MyTemplate.vstemplate' auto created file.
    The remaining SimpleProjectTemplate.vstemplate 's 
     content has been modified as follows.

    After that, I compressed this folder into a .zip file and placed it in the project template folder, and it came to be displayed in the "Create a new Project" dialog.

    By the way, the [MyTemplate.vstemplate] in the original .zip file was not created by me, it is automatically contained in the .zip file created by "Creating Project Template" instruction in the "Project" menu.I myself did not make any modification on it.

    In my opinion, the .zip file content in the current template export menu and the .zip file format in the template folder recognized by Visual Studio do not match well.

    That's all.

    Once again, thank you for your help.


    Tuesday, April 7, 2020 4:00 PM