Skip to content

Commit

Permalink
Add MakeProxyJsonFileEmbeddedStep
Browse files Browse the repository at this point in the history
  • Loading branch information
realLiangshiwei committed Dec 30, 2021
1 parent d7503ba commit b4e4c92
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
@@ -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());
}
}
}
}

0 comments on commit b4e4c92

Please sign in to comment.