Search code examples
visual-studiovisual-studio-2017visual-studio-templates

Visual studio 2017 Community project template


I have tried to create a custom project template for Visual Studio Community 2017 for c++. I have exported the project as a template, however when I try to access the files I added in a new project, they are not created in the project folder. I can try to open them in the Solution Explorer, but the files themselves are not being created. I have tried to add <CreateinPlace>true</CreateInPlace> as well as adding the .zip files to the VS template directory, but these had no effect. How would I be able to add the files to the template and get them to show up in a new project?


Solution

  • What it actually was is that the .vstemplate wasn't adding the files as project items, so when I exported the project, it didn't know to look for them. To fix it I just added

    <TemplateContent>
            <Project TargetFileName="CS235-Template.vcxproj" File="CS235-Template.vcxproj" ReplaceParameters="true">
                <ProjectItem ReplaceParameters="false" TargetFileName="$projectname$.vcxproj.filters">CS235-Template.vcxproj.filters</ProjectItem>
                <ProjectItem ReplaceParameters="true" TargetFileName="main.cpp">main.cpp</ProjectItem>
                <ProjectItem ReplaceParameters="true" TargetFileName="Debug.h">Debug.h</ProjectItem>
                <ProjectItem ReplaceParameters="true" TargetFileName="input.txt">input.txt</ProjectItem>
            </Project>
        </TemplateContent>
    

    After doing this they worked just fine.