/// <summary>
        /// Adds the project to template.
        /// </summary>
        /// <param name="project">The project.</param>
        /// <param name="vsTemplate">The vs template.</param>
        /// <param name="contextNode">The context node.</param>
        private void AddAssetsToTemplate(Project project, VSSolutionTemplate vsTemplate, XmlNode contextNode)
        {
            if(project.Object is SolutionFolder)
            {
                //Add SolutionFolder node
                SolutionFolder solutionFolder = project.Object as SolutionFolder;
                XmlNode solutionFolderNode = vsTemplate.CreateSolutionFolderNode(solutionFolder.Parent.Name);
                contextNode.AppendChild(solutionFolderNode);

                foreach(ProjectItem item in project.ProjectItems)
                {
                    if(item.Object != null &&
                        (item.Object is Project ||
                        ((Project)item.Object).Object is SolutionFolder))
                    {
                        AddAssetsToTemplate((Project)item.Object, vsTemplate, solutionFolderNode);
                    }
                }
            }
            else
            {
                string projectName;

                if(project.Object is VSWebSite)
                {
                    projectName = VSTemplateExporterHelper.GetProjectName(project.UniqueName);
                }
                else
                {
                    projectName = project.Name;
                }

                string relativeTemplatePath = Path.Combine
                                                (
                                                    Path.Combine(this.ProjectsDirectory, projectName),
                                                    string.Concat(projectName, VSTemplateExporterHelper.TEMPLATE_EXTENSION)
                                                );

                XmlNode projectTemplateLinkNode = vsTemplate.CreateProjectTemplateLinkNode(projectName, relativeTemplatePath);

                contextNode.AppendChild(projectTemplateLinkNode);

                //Create project template
                VSProjectTemplateExporter webProjectExporter = new VSProjectTemplateExporter(
                        project,
                        this.projectsTemplateIconFile,
                        outputProjectsDirectory);

                webProjectExporter.Export();
            }
        }
        /// <summary>
        /// Exports this instance.
        /// </summary>
        public void Export()
        {
            string solutionName = this.Solution.Properties.Item("Name").Value.ToString();

            //Clean or create output directory
            VSTemplateExporterHelper.CreateDirectoryIfNotExists(this.OutputDirectory);

            //Copy solution template icon file
            string outputSolutionTemplateIconFile = Path.Combine(
                                        this.OutputDirectory,
                                        Path.GetFileName(this.solutionTemplateIconFile));
            // Check if we need to copy to output or not
            if (!this.solutionTemplateIconFile.Equals(outputSolutionTemplateIconFile,
                StringComparison.InvariantCultureIgnoreCase))
            {
                File.Copy(this.solutionTemplateIconFile, outputSolutionTemplateIconFile, true);
            }

            VSSolutionTemplate vsTemplate = new VSSolutionTemplate();
            vsTemplate.Name = solutionName;
            vsTemplate.Description = solutionName;
            vsTemplate.DefaultName = solutionName;
            vsTemplate.Icon = Path.GetFileName(this.SolutionTemplateIconFile);

            XmlNode rootNode = vsTemplate.CreateRootNode();
            XmlNode templateContentNode = vsTemplate.CreateTemplateContentNode();
            XmlNode projectCollectionNode = vsTemplate.CreateProjecCollectiontNode();

            foreach(Project project in this.Solution.Projects)
            {
                //Add ProjectTemplateLink and SolutionFolder nodes
                //Create project templates
                AddAssetsToTemplate(project, vsTemplate, projectCollectionNode);
            }

            rootNode.AppendChild(vsTemplate.CreateTemplateDataNode());
            templateContentNode.AppendChild(projectCollectionNode);
            rootNode.AppendChild(templateContentNode);
            rootNode.AppendChild(vsTemplate.CreateWizardExtensionNode());
            rootNode.AppendChild(vsTemplate.CreateWizardDataNode());

            //Save solution template
            vsTemplate.Save(
                this.OutputDirectory,
                string.Concat(solutionName,VSTemplateExporterHelper.TEMPLATE_EXTENSION));
        }