public static void CreateAppSettings(string solutionDirectory, ApiEnvironment env, string dbName, ApiTemplate template) { try { var appSettingFilename = Utilities.GetAppSettingsName(env.EnvironmentName); var classPath = ClassPathHelper.AppSettingsClassPath(solutionDirectory, $"{appSettingFilename}"); if (!Directory.Exists(classPath.ClassDirectory)) { Directory.CreateDirectory(classPath.ClassDirectory); } if (File.Exists(classPath.FullClassPath)) { File.Delete(classPath.FullClassPath); } using (FileStream fs = File.Create(classPath.FullClassPath)) { var data = ""; data = GetAppSettingsText(env, dbName, template); fs.Write(Encoding.UTF8.GetBytes(data)); } GlobalSingleton.AddCreatedFile(classPath.FullClassPath.Replace($"{solutionDirectory}{Path.DirectorySeparatorChar}", "")); } catch (FileAlreadyExistsException e) { WriteError(e.Message); throw; } catch (Exception e) { WriteError($"An unhandled exception occurred when running the API command.\nThe error details are: \n{e.Message}"); throw; } }