/// <summary>
        /// Gets the template info to be used when applying the template
        /// First checks for the existing solution-local template info file. If exists, the reference to the template (template dir) is retrieved from the file  and such template is used
        /// When there is no local template file, it checks the template directory (defined in package settings).
        /// When a single template is available, the template is used
        /// When there are multiple templates available, a dialog with the list of templates is presented to user to choose the template
        /// </summary>
        /// <param name="solutionInfo">Current information about the opened solution</param>
        /// <returns>Template info (template) to be used or null when the action has been canceled by user or no templates are available</returns>
        private TemplateInfo GetTemplateInfo(SolutionInfo solutionInfo)
        {
            TemplateInfo templateInfo;
            //check for existing solution template first
            var existingLocalTemplateFile = solutionInfo.SolutionDir.AddPath(TemplateInfoFileName);

            if (File.Exists(existingLocalTemplateFile))
            {
                //if the local (solution) template exists, use it to get the reference to the template used by solution
                templateInfo = TemplateInfo.Load(existingLocalTemplateFile);
                Package.Output($"Using existing solution template file to identify template");
                if (!Directory.Exists(templateInfo.TemplateDir))
                {
                    throw new Exception($"Template directory {templateInfo.TemplateDir} doesn't exist");
                }

                //but use the template file (at template) for the processing to ensure the changes in template definition (the template file may be updated)
                var originalTemplateFile = templateInfo.TemplateDir.AddPath(TemplateInfoFileName);
                if (!File.Exists(originalTemplateFile))
                {
                    throw new Exception($"Original template file {originalTemplateFile} doesn't exist");
                }

                templateInfo             = TemplateInfo.Load(originalTemplateFile);
                templateInfo.TemplateDir = new FileInfo(originalTemplateFile).DirectoryName;
            }
            else
            {
                var templates = GetTemplates();
                if (templates.Count == 0)
                {
                    Package.Output($"No template found");
                    Package.MessageBoxWarn("No template found", "Apply template");
                    return(null);
                }

                templateInfo = templates.First();
                if (templates.Count <= 1)
                {
                    return(templateInfo);
                }

                //select template
                var dlg = new ChooseTemplateDialogWindow(Package, templates)
                {
                    Owner = Application.Current.MainWindow
                };
                if (dlg.ShowMe(true) != true)
                {
                    return(null);
                }

                templateInfo = dlg.SelectedTemplateInfo;
            }

            return(templateInfo);
        }
        /// <summary>
        /// Gets the list of templates available in the templates directory defined in package settings
        /// </summary>
        /// <returns>List of templates available in the templates directory defined in package settings (empty when no templates are available)</returns>
        public List <TemplateInfo> GetTemplates()
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var retVal = new List <TemplateInfo>();

            var templatesPath = RadProjectsExtensionOptions.ApplyVariables(Options?.TemplatesDir ?? RadProjectsExtensionOptions.DefaultTemplatesDir, Dte);

            Package.Output($"Checking templates in {templatesPath}...");
            var templatesDir = new DirectoryInfo(templatesPath);
            var templateDirs = templatesDir.GetDirectories().Where(di => File.Exists(di.FullName.AddPath(TemplateInfoFileName)));

            foreach (var templateDir in templateDirs)
            {
                var templateFile = templateDir.FullName.AddPath(TemplateInfoFileName);
                var templateInfo = TemplateInfo.Load(templateFile);
                templateInfo.TemplateDir = templateDir.FullName;
                retVal.Add(templateInfo);
            }
            Package.Output($"Found {retVal.Count} templates in {templatesPath}");
            return(retVal);
        }