Skip to content

Commit 8e5704f

Browse files
authored
Merge pull request #23850 from abpframework/cli-fix-directory-problem-in-csharp-proxy-generatror
Cli: fix directory problem in csharp proxy generatror
2 parents af5244d + 9b5ad64 commit 8e5704f

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/ServiceProxying/CSharp/CSharpServiceProxyGenerator.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Volo.Abp.Cli.Http;
1010
using Volo.Abp.DependencyInjection;
1111
using Volo.Abp.Http.Modeling;
12+
using Volo.Abp.IO;
1213
using Volo.Abp.Json;
1314

1415
namespace Volo.Abp.Cli.ServiceProxying.CSharp;
@@ -162,7 +163,10 @@ public async override Task GenerateProxyAsync(GenerateProxyArgs args)
162163
private async Task CreateJsonFile(GenerateProxyArgs args, ApplicationApiDescriptionModel applicationApiDescriptionModel)
163164
{
164165
var folder = args.Folder.IsNullOrWhiteSpace() ? ProxyDirectory : args.Folder;
165-
var filePath = Path.Combine(args.WorkDirectory, folder, $"{args.Module}-generate-proxy.json");
166+
var directory = Path.Combine(args.WorkDirectory, folder);
167+
DirectoryHelper.CreateIfNotExists(directory);
168+
169+
var filePath = Path.Combine(directory, $"{args.Module}-generate-proxy.json");
166170
using (var writer = new StreamWriter(filePath))
167171
{
168172
await writer.WriteAsync(JsonSerializer.Serialize(applicationApiDescriptionModel, indented: true));
@@ -187,7 +191,7 @@ private async Task GenerateClassFileAsync(
187191
classTemplateEmptyPart.Replace(NamespacePlaceholder, rootNamespace);
188192

189193
var filePath = Path.Combine(args.WorkDirectory, folder, $"{clientProxyName}.cs");
190-
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
194+
DirectoryHelper.CreateIfNotExists(Path.GetDirectoryName(filePath)!);
191195
if (!File.Exists(filePath))
192196
{
193197
using (var writer = new StreamWriter(filePath))
@@ -223,7 +227,7 @@ private async Task GenerateClassFileAsync(
223227
classTemplate.Replace($"{Environment.NewLine}{Environment.NewLine} {MethodPlaceholder}", string.Empty).Replace(MethodPlaceholder, string.Empty);
224228

225229
filePath = Path.Combine(args.WorkDirectory, folder, $"{clientProxyName}.Generated.cs");
226-
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
230+
DirectoryHelper.CreateIfNotExists(Path.GetDirectoryName(filePath)!);
227231
using (var writer = new StreamWriter(filePath))
228232
{
229233
await writer.WriteAsync(classTemplate.ToString());
@@ -253,7 +257,7 @@ private async Task GenerateClassFileAsync(
253257
interfaceTemplate.Replace(NamespacePlaceholder, rootNamespace);
254258

255259
filePath = Path.Combine(args.WorkDirectory, folder, $"{appServiceTypeName}.cs");
256-
Directory.CreateDirectory(Path.GetDirectoryName(filePath));
260+
DirectoryHelper.CreateIfNotExists(Path.GetDirectoryName(filePath)!);
257261
using (var writer = new StreamWriter(filePath))
258262
{
259263
await writer.WriteAsync(interfaceTemplate.ToString());

0 commit comments

Comments
 (0)