title: Howto add existing projects to visual studio project via template wizard
body: <p>I would like to add existing projects to a new solution generated by a template. Can I achieve this via vstemplate file or do I have to use IWizard. And if I have to use IWizard how can I correctly work with it. Currently I tried the following:</p>
  
  <ol>
  <li>multiproject template which adds some solution folders and one project</li>
  <li>wizard with custom wizarddata. $wizarddata$ contains some relative paths to projects which already exists on harddrive. In the wizard I select the basepath for these projects. How can I add this project now to my solution?</li>
  </ol>
  
  <p>The main problem seems to be that the Solution object does not contain anything:</p>
  
  <pre><code>var type = Type.GetTypeFromProgID("VisualStudio.DTE.10.0");
  var dte2 = (EnvDTE80.DTE2)Activator.CreateInstance(type);
  var solution = (EnvDTE100.Solution4)dte2.Solution;
  var projects = dte2.ActiveSolutionProjects;
  </code></pre>
  
  <p>projects does not contain any project. The same applies for dte2.Solution.Projects. This code is called in the RunFinished function of the IWizard implementation. Or:</p>
  
  <pre><code>var type = Type.GetTypeFromProgID("VisualStudio.DTE.10.0");
  var dte2 = (EnvDTE80.DTE2)Activator.CreateInstance(type);
  dte2.ExecuteCommand("File.AddExistingProject", "X:\\Path\\To\\Project\\ProjectName.csproj");
  </code></pre>
  
  <p>will throw an COM-Exception. If i execute the ExecuteCommand from a macro in a visual studio it will work fine. What am I doing wrong?</p>