Exported project template in VS2017 misses source files

后端 未结 3 1869
后悔当初
后悔当初 2020-12-17 23:09

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 *.cp

相关标签:
3条回答
  • 2020-12-17 23:36

    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.

    0 讨论(0)
  • 2020-12-17 23:46

    yeah, I just put the source within it, ...I've had luck exporting code from github because it contains multiple projects... It's this stupid thing ... under Project Dependencies "The Project Dependencies option is only available in a solution with more than one project" so I have no option to select the source. ...they made it like this on purpose but I don't know why.

    0 讨论(0)
  • 2020-12-17 23:55

    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>
    
    0 讨论(0)
提交回复
热议问题