From 405a3e5d0ff64e03aede9819a6cb7280bcf2f6f6 Mon Sep 17 00:00:00 2001 From: Yunus Emre Kalkan Date: Thu, 9 Sep 2021 14:01:09 +0300 Subject: [PATCH] Cli: Modify abpmdl.json files on project creation --- .../Steps/RemoveProjectFromSolutionStep.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/RemoveProjectFromSolutionStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/RemoveProjectFromSolutionStep.cs index b8c1f24b46..84dd789cb7 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/RemoveProjectFromSolutionStep.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/RemoveProjectFromSolutionStep.cs @@ -1,6 +1,10 @@ using System; using System.Collections.Generic; +using System.IO; using System.Linq; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Volo.Abp.Cli.ProjectBuilding.Files; namespace Volo.Abp.Cli.ProjectBuilding.Building.Steps { @@ -35,6 +39,25 @@ namespace Volo.Abp.Cli.ProjectBuilding.Building.Steps var solutionFile = context.GetFile(_solutionFilePath); solutionFile.NormalizeLineEndings(); solutionFile.SetLines(RemoveProject(solutionFile.GetLines().ToList())); + + RemoveProjectFromAbpmdlFile(context); + } + + private void RemoveProjectFromAbpmdlFile(ProjectBuildContext context) + { + var abpmdlFile = context.FindFile(_solutionFilePath.RemovePostFix(".sln") + ".abpmdl.json"); + + if (abpmdlFile == null) + { + return; + } + + var jsonRoot = JObject.Parse(abpmdlFile.Content); + var packagesObj = (JObject) jsonRoot["packages"]; + + packagesObj.Remove(_projectName); + + abpmdlFile.SetContent(jsonRoot.ToString(Formatting.Indented)); } private List RemoveProject(List solutionFileLines)