Since no one was able to answer the question about FTE ...
I do not like the mass of default settings in Visual C ++ projects. I decided to make a standard blank for myself - I created a project, carefully set properties, created a source code with template text included in the project. Saved as a template. Everything is there, everything opens, the project is being created.

There is only my source file with the source code. When trying to add it yourself to .zip and register as <ProjectItem> , it seems to be indicated in the project, but when you try to open it, it is reported that there is no such file (and it really is not in the created directory).

For some reason, this question has been completely ignored on the Internet (at least I could not find the answer).

Tell me what am I doing wrong? How to make the source to create (with the name selected for the project), and that it was automatically opened in the editor window?

    1 answer 1

    There was the same problem. My decision was:

    1. We create a project template in the usual way with the necessary project parameters, etc.
    2. Follow the path Documents\Visual Studio 2017\Templates\ProjectTemplates and find our archive with the template there. (In this moment, I suffered for a long time, since VS opened the Documents\Visual Studio 2017\My Exported Templates folder for me when exporting, but it does not work with this folder)
    3. Add missing source files with template text to our archive.
    4. .vstemplate file in this archive by adding it as you said <ProjectItem> in this way (do not forget to change your names):

    Before:

     <Project TargetFileName="Project.vcxproj" File="Project.vcxproj" ReplaceParameters="true"> <ProjectItem ReplaceParameters="false" TargetFileName="$projectname$.vcxproj.filters">Project.vcxproj.filters</ProjectItem> </Project> 

    After:

     <Project TargetFileName="Project.vcxproj" File="Project.vcxproj" ReplaceParameters="true"> <ProjectItem ReplaceParameters="false" TargetFileName="$projectname$.vcxproj.filters">Project.vcxproj.filters</ProjectItem> <ProjectItem ReplaceParameters="false" TargetFileName="main.cpp">main.cpp</ProjectItem> </Project> 
    1. Reboot VS

    To make the element automatically open, we add the attribute OpenInEditor="true" to <ProjectItem> :

     <ProjectItem ReplaceParameters="false" TargetFileName="main.cpp" OpenInEditor="true">main.cpp</ProjectItem> 
    • It worked :) But ... "How honey is like a spoon" - if I replace with TargetFileName="$projectname$.cpp" , then nothing works ... You can somehow explain to him that in the template the source code should be called by project name? And yet - I would like to have a comment in the source file with the time / date of creation, for example. Are there any macros on this topic? Well, the last thing - and indicate where the cursor should be in the blank file when the editor is opened - how about this? So that not at the beginning, but closer to the end ... :) - Harry