99using Volo . Abp . Cli . Http ;
1010using Volo . Abp . DependencyInjection ;
1111using Volo . Abp . Http . Modeling ;
12+ using Volo . Abp . IO ;
1213using Volo . Abp . Json ;
1314
1415namespace Volo . Abp . Cli . ServiceProxying . CSharp ;
@@ -162,7 +163,10 @@ public override async 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