public virtual void CreateNestedProjectNodes()
{
// 1. Create a ProjectElement with the found item and then Instantiate a new Nested project with this ProjectElement.
// 2. Link into the hierarchy.
// Read subprojects from from msbuildmodel
__VSCREATEPROJFLAGS creationFlags = __VSCREATEPROJFLAGS.CPF_NOTINSLNEXPLR | __VSCREATEPROJFLAGS.CPF_SILENT;
if(this.IsNewProject)
{
creationFlags |= __VSCREATEPROJFLAGS.CPF_CLONEFILE;
}
else
{
creationFlags |= __VSCREATEPROJFLAGS.CPF_OPENFILE;
}
foreach (MSBuild.ProjectItem item in this.BuildProject.Items)
{
if(String.Equals(item.ItemType, ProjectFileConstants.SubProject, StringComparison.OrdinalIgnoreCase))
{
this.nestedProjectElement = new ProjectElement(this, item, false);
if(!this.IsNewProject)
{
AddExistingNestedProject(null, creationFlags);
}
else
{
// If we are creating the subproject from a vstemplate/vsz file
bool isVsTemplate = Utilities.IsTemplateFile(GetProjectTemplatePath(null));
if(isVsTemplate)
{
RunVSTemplateWizard(null, true);
}
else
{
// We are cloning the specified project file
AddNestedProjectFromTemplate(null, creationFlags);
}
}
}
}
this.nestedProjectElement = null;
}