/// <summary> /// Creates the custom configuration file. /// </summary> /// <param name="name">The name.</param> /// <param name="configFolderPath">The config folder path.</param> /// <param name="folder">The folder.</param> /// <returns></returns> private string CreateCustomConfigurationFile(string name, string configFolderPath, ProjectItem folder) { IShellHelper shell = ServiceLocator.Instance.GetService <IShellHelper>(); // Calcule le nom du fichier personnalisable string customFileName = String.Concat(name, ".config"); string customFilePath = Path.Combine(configFolderPath, customFileName); XmlDocument xdoc = new XmlDocument(); // Ajout si n'existe pas if (!File.Exists(customFilePath)) { // On regarde si il n'existe pas un template bool fileCreated = false; string templateFileName = String.Format(_templateFormatName, name); RepositoryFile rf = new RepositoryFile(RepositoryCategory.T4Templates, Path.Combine("ConfigFiles", templateFileName)); try { if (rf.Exists()) { xdoc.Load(rf.LocalPhysicalPath); fileCreated = true; } } catch { } // Si on est pas arrivé à en créer un à partir d'un template, on en crée un vide. if (!fileCreated) { xdoc.LoadXml(@"<?xml version=""1.0"" encoding=""utf-8"" ?><configuration/>"); } xdoc.Save(customFilePath); shell.AddFileToFolder(folder, customFilePath); } else { xdoc.Load(customFilePath); } return(customFilePath); }