none
Mutli-File Project Templates in Visual Studio

    Question

  • Is there a way in Visual Studio to save a project as a template where if I create a new project based on the template, all the source files will be there?
    Sunday, July 03, 2016 11:28 AM

Answers

  • Hi Matthew S H,

    What's the source file did you add into your porject?

    As far as I know, the source will exist in the .zip folder.

    >>I looked in .zip where the template is saved, and lo behold no source files are there.

    I think the cause is that the source files are not exist in the location which .zip saved. So when you open this source file in solution explorer. It shows "File does not exist". Did you manually delete the source file in this folder?

    By the way, how about creating a new project and add a simple source file like a class file. Then save as an project template.

    Use this template to create the project.  Does it have the same problem when open the source file?

    In addition, I suggest you could try to create new project template, then check whether the source files were existed in that location. Then create this project use the new project template again.

    Best Regards,

    Lake Xiao


    Thursday, July 07, 2016 1:03 AM
    Moderator

All replies

  • Hi Matthew S H,

    >>Is there a way in Visual Studio to save a project as a template where if I create a new project based on the template, all the source files will be there?

    Yes, you can custom project template with the standard Export Template wizard.

    1.Open an existed project.

    2.File->Export Template, select Project Template, click Next.

    3.Input the new template name and click finish.

    4.Reopen your Visual Studio. Then it will appear in the New Project dialog box.

    Best Regards,

    Lake Xiao

    Monday, July 04, 2016 6:40 AM
    Moderator
  • Thanks for the reply.

    However, I do this already and when I create the project based on the template, all the source files are gone

    Monday, July 04, 2016 4:14 PM
  • Hi Matthew S H,

    >>However, I do this already and when I create the project based on the template, all the source files are gone

    The source files were already added into the project when I create the project use my custom project template.

    For example: I created a unit test project. Add some code into it and add a class file. When I save this as a new project template. Then I create a new project use this template. All code and files were added into the project.

    So please tell us some more information about your problem.

    Best Regards,

    Lake Xiao

    Tuesday, July 05, 2016 1:04 AM
    Moderator
  • That's all there is to it.

    The files appear in the project explorer, but when I try to open the files from a new project it says "File does not exist".

    I looked in .zip where the template is saved, and lo behold no source files are there.

    Wednesday, July 06, 2016 9:00 PM
  • Hi Matthew S H,

    What's the source file did you add into your porject?

    As far as I know, the source will exist in the .zip folder.

    >>I looked in .zip where the template is saved, and lo behold no source files are there.

    I think the cause is that the source files are not exist in the location which .zip saved. So when you open this source file in solution explorer. It shows "File does not exist". Did you manually delete the source file in this folder?

    By the way, how about creating a new project and add a simple source file like a class file. Then save as an project template.

    Use this template to create the project.  Does it have the same problem when open the source file?

    In addition, I suggest you could try to create new project template, then check whether the source files were existed in that location. Then create this project use the new project template again.

    Best Regards,

    Lake Xiao


    Thursday, July 07, 2016 1:03 AM
    Moderator
  • I will try and get back to you.

    I should have probably noted this is using Visual C++, not C#

    Friday, July 08, 2016 10:39 PM
  • Hi Matthew S H,

    I also tested using C++ project, and the custom template for C++ project was correct as well.

    Please try to create a new C++ project, right click you project and add a new item, add any source file. Export this project as a custom project template then try it again.

    Best Regards,

    Lake Xiao

    Monday, July 11, 2016 1:14 AM
    Moderator
  • Thanks!
    Tuesday, July 12, 2016 3:29 PM