Exported project template in VS2017 misses source files

北慕城南 提交于 2019-12-18 04:47:06

问题


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.


回答1:


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>



回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/48553375/exported-project-template-in-vs2017-misses-source-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!