Adding existing project with template

I am creating a solution template, which needs to have a couple of shared existing project in it in addition to the new templated project. I couldn't figure out how to add existing projects to the solution with project template and/or solution template. Any one can help me

Answer this question

Adding existing project with template

  • SecurityCoder

    Craig,

    Thanks for the reply.

    I don't understand why the template doesn't provide this simple option to add an existing project. Actually, all it needs to changes is just the sln file. It looks quite simple to me to have it supported.

    I also noticed that the DTE.Solutions.LoadFromFile() method can add an existing project, but this probably makes things too complicated. By the way, if the existing project is under source control, the DTE seems not support adding/creating projects which are under source control.

    James


  • Fausto_Jasso

    Because the wizard is about creating new projects and new project items, not manipulating existing files. It is also very error prone, if you have a template which requires the existance of an existing project, you will need a tag like this:

    <ExistingProject Path="My Documents\Visual Studio 2005\Projects\MySolutionName\MyProjectName\ProjectFile.someproj"/>

    Now what if the user typed a solution name, project directory, or project file name that differs from what your template expected Should the wizard error out, prompt to find the new project file, or should it just create an unloaded project If we allowed you to browse to an existing project file, and you were requiring a user control project to be referenced but the user browsed to a console application project, what happens then These are all questions that we could enforce one mechanisim, but it would not work for every single need out there.

    If what you need to do is create a grouping of projects, then you should be using a group project template, not one project file and adding a reference to another exitsing project. If you really do need this functionality, then you should build it in using a wizard extension and use the mechanism that is best for you.

    If we were to implement a way to reference an existing project, we would use Solution.AddFromFile, that is exactly what it was designed for.

    We do not automatically add files to SCC. The automation model is built to do small, atomic actions, not make assumptions about what the user may want to do. If the user wanted to create a new project in the solution, but not check it in yet, if we did that automatically then the user would not be happy. Instead, we have the DTE.SourceControl object to all you to build functionality into your Add-in or macro do do this, but only when you want it to.

    Craig



  • proggerFX

    There is no way to reference an existing project to add to a new solution, as this would require specific knowledge about the computer's directory layout. You can implement an IWizard DLL to plug into the wizard, and in that DLL you can add the project reference manually, if you wish.

    Craig



  • Adding existing project with template