Source / header files are not created when exporting a template containing them

  • Create a new project
  • add 2 files, driver.h (under the file headers) and driver.cpp (in the source files)
  • Add content, such as #include to the header file, and include this header file in the .cpp file
  • file <export template
  • project template, click Next.
  • add a template name, description, do not care about the icon or image, so leave it blank.
  • complete and then create a project using the above template.

Now I have a ZIP folder in the exported templates containing the template that we named above (we just say the project template). The problem is that when I create a new project using this template, the .h and .cpp files are referenced in the solution explorer, but they do not exist: enter image description here

And if I try to click on driver.cpp or driver.h, I get the following error enter image description here

But if I insert driver.h and driver.cpp files in this place, they work enter image description here

It hurts to have a template if I need to insert files for this to work, why are these files missing and still exist in the file explorer? Why does this not save the contents of the exported template? What do I need to do so that the template automatically creates two drivers.cpp and driver.h files, so I don’t need to go through this process every time I create a project that needs the same files?

+6
source share
2 answers

I had the same problem. The problem is that there is an error in the VS Export template procedure that does not copy files that are organized into project subdirectories. ex ... \ Source Files \ driver.cpp

This is what I did as a workaround

  • Delete old (confused) templates: goto β†’ C: \ Users \ xxxx \ AppData \ Roaming \ Microsoft \ VisualStudio \ 14.0 \ ProjectTemplatesCache Delete the xxxx.zip directories that you no longer need.

  • Close and reopen Visual Studio. (you can check if the templates are gone - File / New / Project ...

  • Create your project as you would like.

  • Click and drag all headers and source files to the project root directory

  • File / Export Template.,

  • Now when you open the project based on the template, all the files will be there, and you can simply click and drag them under the corresponding subfolder.

Hooray!

+3
source

Instead of using Add New Item... , I found that a somewhat clean workaround is to simply drag and drop the files you need into the project. This will include them when exporting the template.

+1
source

Source: https://habr.com/ru/post/1012366/


All Articles