private void AddTemplateFoldersParameterIfPossible(ScaffolderInfo scaffolder, Hashtable paramsTable, Project project)
        {
            // Specified overrides are the top priority folders to search
            List <string> templateFolders = new List <string>();

            if (OverrideTemplateFolders != null)
            {
                templateFolders.AddRange(OverrideTemplateFolders.Select(x => x.ToString()));
            }

            // If not found in these, the scaffolder should look in its own custom templates folder plus the same folder under "tools" that it actually lives in
            templateFolders.Add(GetCustomTemplateFolder(scaffolder.Name, project));
            templateFolders.Add(Path.GetDirectoryName(scaffolder.Location));

            AddParameterIfAcceptedByScaffolder(scaffolder.Command, paramsTable, "TemplateFolders", templateFolders.Where(x => !string.IsNullOrEmpty(x)).ToArray());
        }
        private void InvokeScaffolderCore(Project project, ScaffolderInfo scaffolder)
        {
            var scaffolderParams = new Hashtable(CommandInvoker.BoundParameters
                                                 .Where(x => !StaticParameterNames.Contains(x.Key, StringComparer.OrdinalIgnoreCase))
                                                 .ToDictionary(x => x.Key, x => x.Value));

            AddTemplateFoldersParameterIfPossible(scaffolder, scaffolderParams, project);
            AddParameterIfAcceptedByScaffolder(scaffolder.Command, scaffolderParams, "Project", project.Name);

            using (var stack = new CallStackDepthCounter()) {
                // Don't pipe output when the scaffolder is invoked directly from the console.
                // Only pipe it for inner invocations (e.g., when a scaffolder is invoked by another script)
                // This behaviour can be overridden using the PipeOutput switch
                var pipelineType = (stack.Depth > 0) || PipeOutput.IsPresent ? PipelineResultTypes.Output | PipelineResultTypes.Error : PipelineResultTypes.Error;
                CommandInvoker.InvokePipeToOutput(scaffolder.Command, scaffolderParams, pipelineType);
            }
        }