Type vsType = Type.GetTypeFromProgID("VisualStudio.DTE.10.0");
DTE dte = Activator.CreateInstance(vsType) as DTE;
Solution2 soln = (Solution2)dte.Solution;
string prjPath=@”C:\My Project”; // Project Path – where the new solution is created
string templatePath; // path of ConsoleApplication Template
templatePath = soln.GetProjectTemplate("ConsoleApplication.zip", "vbproj");
soln.AddFromTemplate(templatePath, prjPath, "My Project", false);
To add a custom template ( template created from a project), we can directly specify the template location in AddFromTemplate method as follows –
soln.AddFromTemplate(@"C:\DataAccess.zip\CustomTemplate.vstemplate", csPrjPath, "Sample Windows Application", false);
Related Links:
http://msdn.microsoft.com/en-us/library/envdte.projectitems.addfromtemplate(v=vs.100).aspx