From 8232f51855911b3e8e9724dbdef2898b50ec56aa Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Tue, 26 Apr 2022 14:19:33 +0300 Subject: [PATCH 1/2] Cli: Improve CreateAppSettingsSecretsStep --- .../Steps/CreateAppSettingsSecretsStep.cs | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/CreateAppSettingsSecretsStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/CreateAppSettingsSecretsStep.cs index 7a5f792b15..aea368ac47 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/CreateAppSettingsSecretsStep.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/CreateAppSettingsSecretsStep.cs @@ -30,7 +30,9 @@ public class CreateAppSettingsSecretsStep : ProjectBuildPipelineStep ); } - var projectFiles = context.Files.Where(x => x.Content.Contains(AppSettingsPlaceholder)).ToList(); + var projectFiles = context.Files.Where(x => + x.Name.EndsWith(CliConsts.AppSettingsJsonFileName) && + x.Content.Contains(AppSettingsPlaceholder)).ToList(); foreach (var projectFile in projectFiles) { @@ -66,11 +68,30 @@ public class CreateAppSettingsSecretsStep : ProjectBuildPipelineStep private static string ReplaceAppSettingsSecretsPlaceholder(string content) { - var replaceContent = $"{Environment.NewLine}" + - $" {Environment.NewLine}" + + var path = string.Empty; + + var appSettingsRemoveLine = content.SplitToLines().FirstOrDefault(l=> + l.Contains("None") && + l.Contains("Remove") && + l.Contains(CliConsts.AppSettingsJsonFileName)); + + if (appSettingsRemoveLine != null) + { + var prefix = appSettingsRemoveLine.Split("\"") + .Select(s => s.Trim()) + .First(s => s.Contains(CliConsts.AppSettingsJsonFileName)) + .Replace(CliConsts.AppSettingsJsonFileName, ""); + + path = string.IsNullOrWhiteSpace(prefix) ? string.Empty : prefix; + } + + + var replaceContent = $"{Environment.NewLine}" + + $" {Environment.NewLine}" + $" PreserveNewest{Environment.NewLine}" + $" Always{Environment.NewLine}" + " "; + return content.Replace(AppSettingsPlaceholder, replaceContent); } } \ No newline at end of file From 9e4ecede687da8a192bc4181a4211415d031240b Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Tue, 26 Apr 2022 14:27:41 +0300 Subject: [PATCH 2/2] Update CreateAppSettingsSecretsStep.cs --- .../Building/Steps/CreateAppSettingsSecretsStep.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/CreateAppSettingsSecretsStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/CreateAppSettingsSecretsStep.cs index aea368ac47..20e4f8fca6 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/CreateAppSettingsSecretsStep.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/CreateAppSettingsSecretsStep.cs @@ -31,7 +31,7 @@ public class CreateAppSettingsSecretsStep : ProjectBuildPipelineStep } var projectFiles = context.Files.Where(x => - x.Name.EndsWith(CliConsts.AppSettingsJsonFileName) && + x.Name.EndsWith(".csproj") && x.Content.Contains(AppSettingsPlaceholder)).ToList(); foreach (var projectFile in projectFiles)