From b4e4c92ffc42803585b3266ad07020cab83efd9c Mon Sep 17 00:00:00 2001 From: liangshiwei Date: Thu, 30 Dec 2021 16:34:11 +0800 Subject: [PATCH] Add MakeProxyJsonFileEmbeddedStep --- .../ModuleProjectBuildPipelineBuilder.cs | 1 + .../Steps/MakeProxyJsonFileEmbeddedStep.cs | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/MakeProxyJsonFileEmbeddedStep.cs diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/ModuleProjectBuildPipelineBuilder.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/ModuleProjectBuildPipelineBuilder.cs index d4a74d93645..a5f5cb6d7d5 100644 --- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/ModuleProjectBuildPipelineBuilder.cs +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/ModuleProjectBuildPipelineBuilder.cs @@ -12,6 +12,7 @@ public static ProjectBuildPipeline Build(ProjectBuildContext context) pipeline.Steps.Add(new FileEntryListReadStep()); pipeline.Steps.Add(new ProjectReferenceReplaceStep()); pipeline.Steps.Add(new ReplaceCommonPropsStep()); + pipeline.Steps.Add(new MakeProxyJsonFileEmbeddedStep()); pipeline.Steps.Add(new ReplaceConfigureAwaitPropsStep()); pipeline.Steps.Add(new UpdateNuGetConfigStep("/NuGet.Config")); pipeline.Steps.Add(new CreateProjectResultZipStep()); diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/MakeProxyJsonFileEmbeddedStep.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/MakeProxyJsonFileEmbeddedStep.cs new file mode 100644 index 00000000000..f8de4521728 --- /dev/null +++ b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ProjectBuilding/Building/Steps/MakeProxyJsonFileEmbeddedStep.cs @@ -0,0 +1,38 @@ +using System.Linq; +using System.Xml.Linq; +using Volo.Abp.Cli.Utils; + +namespace Volo.Abp.Cli.ProjectBuilding.Building.Steps; + +public class MakeProxyJsonFileEmbeddedStep : ProjectBuildPipelineStep +{ + public override void Execute(ProjectBuildContext context) + { + foreach (var file in context.Files.Where(x => x.Name.EndsWith(".HttpApi.Client.csproj"))) + { + using (var stream = StreamHelper.GenerateStreamFromString(file.Content)) + { + var doc = XDocument.Load(stream); + + if (doc.Root == null) + { + continue; + } + + var itemGroupNode = + new XElement("ItemGroup", + new XElement("EmbeddedResource", + new XAttribute("Include", @"**\*generate-proxy.json") + ), + new XElement("Content", + new XAttribute("Remove", @"**\*generate-proxy.json") + ) + ); + + doc.Root.Add(itemGroupNode); + + file.SetContent(doc.ToString()); + } + } + } +}