/// <summary> /// Adds solution items from template to target solution - copy the files and add them to solution as Solution Items (when not excluded) /// </summary> /// <param name="templateDirInfo">Template directory's <see cref="DirectoryInfo"/></param> /// <param name="solutionInfo">Information about current solution</param> /// <param name="templateInfo">Information about the template used</param> private void AddSolutionItems(DirectoryInfo templateDirInfo, SolutionInfo solutionInfo, TemplateInfo templateInfo) { ThreadHelper.ThrowIfNotOnUIThread(); foreach (var sourceFileInfo in templateDirInfo.GetFiles().Where(fi => !fi.Name.ToLower().EndsWith(".sln"))) { var destFile = solutionInfo.SolutionDir.AddPath(sourceFileInfo.Name); Package.Output($" Copying solution item from {sourceFileInfo.FullName} to {destFile}..."); FileUtils.FileCopy(sourceFileInfo.FullName, destFile, true, templateInfo.DoNotOverwriteFileNames.ToList()); if (solutionInfo.HasSolutionItem(sourceFileInfo.Name) || templateInfo.DoNotAddToSolution(sourceFileInfo.Name)) { Package.Output( $" Solution item {sourceFileInfo.Name} not added to solution - already exists or blacklisted"); continue; } Package.Output($" Adding solution item {sourceFileInfo.Name} to solution..."); Dte.ToolWindows.SolutionExplorer.UIHierarchyItems.Item(1).Select(vsUISelectionType.vsUISelectionTypeSelect); solutionInfo.Solution.DTE.ItemOperations.AddExistingItem(destFile); Package.Output($" Added solution item {sourceFileInfo.Name} to solution"); } }