Alan
Alan

Reputation: 41

Visual Studio Community 2015 main.cpp missing from template

I created an SFML template and encountered the issue to open main.cpp from the Source Files folder, I got the error message - "The document cannot be opened. It has been renamed, deleted or moved." The next attempt to build the other template gave me the same result. All templates I created in VS 2015 had the same issue, it didn't let me open the main file. I didn't find any useful and similar cases with web search, If someone encountered the similar issues creating his own template in VS 2015, please share the solution how to fix that.

main.cpp didn't open up

I'll be very grateful for any suggestion.

Upvotes: 0

Views: 1294

Answers (1)

Alan
Alan

Reputation: 41

This is a real issue of VS 2015, here's how to solve it:

  1. Follow your steps 1 to 6
  2. At step 7 make sure to uncheck "Automatically import the template into Visual Studio"
  3. Click Finish
  4. Extract the just created zip file of your template to a folder of your choice
  5. Now copy all your source (.cpp) and header (.h) files from your original SFML project to the extracted folder
  6. In this folder look for MyTemplate.vstemplate and open it in a text editor
  7. You will see a TemplateData and TemplateContent section
  8. Inside the TemplateData section add the line true
  9. Inside the TemplateContent section add for each copied file from step 5 the lines filename.cpp or filename.h
  10. Now put all files back into a zip file
  11. Copy your new zip file to Visual Studio 2015\Templates\ProjectTemplates folder
  12. Restart Visual Studio and open a new project from your project template

This blog post helped me figured it out: http://www.mvdcorput.nl/2016/03/creating-visual-studio-2015-project-template/

Upvotes: 1

Related Questions