简体   繁体   中英

How to successfully export C++ project template in Visual Studio 2015?

I went through the steps to export the Visual C++ Project as a Template in Visual Studio 2015. It only contains one file. Main.cpp

When I open the new project created from that template it gives: "files cannot be found" when I try to click on Main.cpp.

I'm missing something, please help.

Ok here is how you do it:

  1. Goto File -> Export Template ...
  2. Select Project Template
  3. In the drop down box select the project you want to use as base
  4. Click Next
  5. Enter all information you want/need on the dialog page
  6. Make sure Display an explorer window on the output files folder is cheked
  7. Click Finish
  8. Open the created zip-archive and add your Main.cpp file to it
  9. Extract and open the MyTemplate.vstemplate in an text-editor The file is an xml-file and the TemplateContent section should look similar to this:
  <TemplateContent> <Project TargetFileName="sample.vcxproj" File="sample.vcxproj" ReplaceParameters="true"> <ProjectItem ReplaceParameters="false" TargetFileName="$projectname$.vcxproj.filters">sample.vcxproj.filters</ProjectItem> </Project> </TemplateContent> 
  1. Now add an ProjectITem for your Main.cpp file it should look like this:
 <ProjectItem ReplaceParameters="false" TargetFileName="Main.cpp">Main.cpp</ProjectItem> 
  1. Save the file and replace the one in the zip-archive

Unfortunately any answer is just going to be a work around -- this functionality is currently broken in Visual Studio 2015, bug has reported in a couple places:

https://github.com/aspnet/Tooling/issues/732

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM