none
Visual Studio doesn't create header or source files when creating project from template

    Question

  • I created a project and then exported it as a template. Whenever I create a new project using the newly created template, it shows the header and source files in the file browser within Visual Studio, but it does not create the files themselves on my computer. Whenever I try to open the source or header files in Visual Studio, it says, "The document cannot be opened. It has been renamed, deleted or moved." I tried saving both the template, and a project using that template, in different locations but it still doesn't work. What is the problem?

    Any help would be greatly appreciated

    Saturday, December 24, 2016 2:36 AM

All replies

  • Hi Nebul601,

    I could repro your issue in my side, and I got the same result as yours. I tried to export C++ template by using VS 2015 update 3.


    Since this issue happened before, someone had submitted a feedback here:

    https://connect.microsoft.com/VisualStudio/feedback/details/2894593/problem-about-export-template-from-c-project

    There is also a workaround posted by psalmsinger2 under the feedback you might refer to it below:

     You need to modify the resulting .vstemplate file within the zip file to include the entries for all the source files that were part of the project:
    Here's an example:
         <ProjectItem ReplaceParameters="false" TargetFileName="Win32DialogBox.cpp">Win32DialogBox.cpp</ProjectItem>
         <ProjectItem ReplaceParameters="false" TargetFileName="resource.h">resource.h</ProjectItem>
         <ProjectItem ReplaceParameters="false" TargetFileName="Win32DialogBox.h">Win32DialogBox.h</ProjectItem>
         <ProjectItem ReplaceParameters="false" TargetFileName="Win32DialogBox.rc">Win32DialogBox.rc</ProjectItem>

    And add the source files to the zip file. I do this by dragging the added/modified files and dropping them on top of the zip file.
    Now, I have found the zip files located at two to three different locations:
    1) "%userprofile%\Documents\Visual Studio 2015\My Exported Templates";
    2) "%userprofile%\Documents\Visual Studio 2015\Templates\ProjectTemplates"; and
    3) sometimes at one of these locations "%userprofile%\AppData\Roaming\Microsoft\WDExpress\14.0\ProjectTemplatesCache" or "%userprofile%\AppData\Roaming\Microsoft\VisualStudio\14.0\ProjectTemplatesCache", depending which Edition of VS2015 you are using.

    Please feel free to let me know If I misunderstand you.

    Best regards,

    Fletcher


    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.



    Monday, December 26, 2016 9:00 AM