从模板创建项目时,Visual Studio不会创建头文件或源文件 [英] Visual Studio doesn't create header or source files when creating project from template

查看:206
本文介绍了从模板创建项目时,Visual Studio不会创建头文件或源文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个项目,然后将其导出为模板.每当我使用新创建的模板创建新项目时,它都会在Visual Studio的文件浏览器中显示标头和源文件,但不会在计算机上自己创建文件. 每当我尝试在Visual Studio中打开源文件或头文件时,都会显示无法打开文档.它已被重命名,删除或移动.我尝试将模板和使用该模板的项目保存在不同的位置,但是 仍然不起作用.有什么问题吗?

I created a project and then exported it as a template. Whenever I create a new project using the newly created template, it shows the header and source files in the file browser within Visual Studio, but it does not create the files themselves on my computer. Whenever I try to open the source or header files in Visual Studio, it says, "The document cannot be opened. It has been renamed, deleted or moved." I tried saving both the template, and a project using that template, in different locations but it still doesn't work. What is the problem?

任何帮助将不胜感激

推荐答案

您好Nebul601,

Hi Nebul601,

我可以帮您解决问题,并且得到与您相同的结果.我试图通过使用VS 2015 Update 3导出C ++模板.

I could repro your issue in my side, and I got the same result as yours. I tried to export C++ template by using VS 2015 update 3.


由于此问题以前发生过,因此有人在此处提交了反馈:

Since this issue happened before, someone had submitted a feedback here:

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

psalmsinger2 还发布了一种变通办法,您可以在下面参考以下反馈:

There is also a workaround posted by psalmsinger2 under the feedback you might refer to it below:

  您需要在zip文件中修改生成的.vstemplate文件,以包括项目中所有源文件的条目:
这是一个例子:
    < ProjectItem ReplaceParameters ="false"; TargetFileName =" Win32DialogBox.cpp"> Win32DialogBox.cpp</ProjectItem>
    < ProjectItem ReplaceParameters ="false"; TargetFileName ="resource.h"> resource.h</ProjectItem>
    < ProjectItem ReplaceParameters ="false"; TargetFileName =" Win32DialogBox.h"> Win32DialogBox.h</ProjectItem>
    < ProjectItem ReplaceParameters ="false"; TargetFileName ="Win32DialogBox.rc"> Win32DialogBox.rc</ProjectItem>

并将源文件添加到zip文件中.我可以通过将添加/修改的文件拖放到zip文件的顶部来完成此操作.
现在,我发现压缩文件位于两个到三个不同的位置:
1)%userprofile%\ Documents \ Visual Studio 2015 \ My Exported Templates";
2)%userprofile%\ Documents \ Visual Studio 2015 \ Templates \ ProjectTemplates";和
3)有时在以下位置之一%userprofile%\ AppData \ Roaming \ Microsoft \ WDExpress \ 14.0 \ ProjectTemplatesCache"或%userprofile%\ AppData \ Roaming \ Microsoft \ VisualStudio \ 14.0 \ ProjectTemplatesCache",具体取决于哪个版本 您正在使用VS2015.

 You need to modify the resulting .vstemplate file within the zip file to include the entries for all the source files that were part of the project:
Here's an example:
     <ProjectItem ReplaceParameters="false" TargetFileName="Win32DialogBox.cpp">Win32DialogBox.cpp</ProjectItem>
     <ProjectItem ReplaceParameters="false" TargetFileName="resource.h">resource.h</ProjectItem>
     <ProjectItem ReplaceParameters="false" TargetFileName="Win32DialogBox.h">Win32DialogBox.h</ProjectItem>
     <ProjectItem ReplaceParameters="false" TargetFileName="Win32DialogBox.rc">Win32DialogBox.rc</ProjectItem>

And add the source files to the zip file. I do this by dragging the added/modified files and dropping them on top of the zip file.
Now, I have found the zip files located at two to three different locations:
1) "%userprofile%\Documents\Visual Studio 2015\My Exported Templates";
2) "%userprofile%\Documents\Visual Studio 2015\Templates\ProjectTemplates"; and
3) sometimes at one of these locations "%userprofile%\AppData\Roaming\Microsoft\WDExpress\14.0\ProjectTemplatesCache" or "%userprofile%\AppData\Roaming\Microsoft\VisualStudio\14.0\ProjectTemplatesCache", depending which Edition of VS2015 you are using.

如果我误解了您,请随时告诉我.

Please feel free to let me know If I misunderstand you.

最诚挚的问候

Fletcher


这篇关于从模板创建项目时,Visual Studio不会创建头文件或源文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆