When I use the Project -> Export template
option in Visual Studio 2017, the resulting ZIP file includes the main project files, but not any of the *.cpp
and *.hpp
files that I've added. How do I include everything with the template? I should also note that this behavior seems to have changed in an update at some point.
On the Project menu, choose Export Template. The Export Template Wizard opens. On the Choose Template Type page, select Project Template. Select the project you want to export to a template, and then choose Next.
For example, you can right-click the project > click properties > select Application and see(refer to) the related information, for example, Output type -- Windows Application, Console Application, Class Library… Or you can find some related information about the project type from items, files etc.
You need to manually edit the .vstemplate file and add <CreateInPlace>true</CreateInPlace>
in the <TemplateData>
tag so it looks like this:
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
<TemplateData>
<Name>TemplateTest</Name>
<Description><No description available></Description>
<ProjectType>JavaScript</ProjectType>
<ProjectSubType>
</ProjectSubType>
<SortOrder>1000</SortOrder>
<CreateNewFolder>true</CreateNewFolder>
<CreateInPlace>true</CreateInPlace>
<DefaultName>CodovaTemplateTest</DefaultName>
<ProvideDefaultName>true</ProvideDefaultName>
<LocationField>Enabled</LocationField>
<EnableLocationBrowseButton>true</EnableLocationBrowseButton>
<Icon>__TemplateIcon.ico</Icon>
</TemplateData>
The problem is in your .vstemplate
file. What you need to do is edit it so that VS knows that there is supposed to be additional files. Unzip the file that was exported, add the files you want, then open the .vstemplate
file. The part of the .vstemplate
you should change is between the <TemplateContent>
tags:
<TemplateContent>
<Project TargetFileName="project.vcxproj" File="project.vcxproj" ReplaceParameters="true">
<ProjectItem ReplaceParameters="false" TargetFileName="$projectname$.vcxproj.filters">project.vcxproj.filters</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="file1.cpp">file1.cpp</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="file2.h">file2.h</ProjectItem>
<ProjectItem ReplaceParameters="true" TargetFileName="input.txt">input.txt</ProjectItem>
</Project>
</TemplateContent>
This tells VS to add the files file1.cpp
, file2.h
and input.txt
to the project when you make it. Just change the names to the files you want, save everything and rezip the folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With