@@ -273,14 +273,15 @@ public override async Task RunAsync()
273273 private void ValidateHostJsonConfiguration ( )
274274 {
275275 bool IsPreCompiledApp = IsPreCompiledFunctionApp ( ) ;
276- if ( IsPreCompiledApp && ! HostJsonExist ( ) )
276+ var hostJsonPath = Path . Combine ( Environment . CurrentDirectory , Constants . HostJsonFileName ) ;
277+ if ( IsPreCompiledApp && ! File . Exists ( hostJsonPath ) )
277278 {
278- throw new CliException ( $ "Host.json file does not exist . Please make sure host.json file is preset at { Environment . CurrentDirectory } ") ;
279+ throw new CliException ( $ "Host.json file in missing . Please make sure host.json file is preset at { Environment . CurrentDirectory } ") ;
279280 }
280281
281- if ( IsPreCompiledApp && BundleConfigurationExists ( ) )
282+ if ( IsPreCompiledApp && BundleConfigurationExists ( hostJsonPath ) )
282283 {
283- throw new CliException ( $ "Extension bundle is configured for the function app with pre-compiled functions. Please remove extension bundle configuration from host.json: { Path . Combine ( Environment . CurrentDirectory , "host.json" ) } ") ;
284+ throw new CliException ( $ "Extension bundle configuration should not be present for the function app with pre-compiled functions. Please remove extension bundle configuration from host.json: { Path . Combine ( Environment . CurrentDirectory , "host.json" ) } ") ;
284285 }
285286 }
286287
@@ -317,30 +318,24 @@ private async Task PreRunConditions()
317318 }
318319 }
319320
320- private bool HostJsonExist ( )
321+ private bool BundleConfigurationExists ( string hostJsonPath )
321322 {
322- var hostJsonPath = Path . Combine ( Environment . CurrentDirectory , "host.json" ) ;
323- return File . Exists ( hostJsonPath ) ;
324- }
325-
326- private bool BundleConfigurationExists ( )
327- {
328- var hostJsonPath = Path . Combine ( Environment . CurrentDirectory , "host.json" ) ;
329323 var hostJson = FileSystemHelpers . ReadAllTextFromFile ( hostJsonPath ) ;
330- return hostJson . Contains ( "extensionBundle" , StringComparison . OrdinalIgnoreCase ) ;
324+ return hostJson . Contains ( Constants . ExtensionBundleConfigPropertyName , StringComparison . OrdinalIgnoreCase ) ;
331325 }
332326
333327 private bool IsPreCompiledFunctionApp ( )
334328 {
335329 bool isPrecompiled = false ;
336330 foreach ( var directory in FileSystemHelpers . GetDirectories ( Environment . CurrentDirectory ) )
337331 {
338- var functionMetadataFile = Path . Combine ( directory , "function.json" ) ;
332+ var functionMetadataFile = Path . Combine ( directory , Constants . FunctionJsonFileName ) ;
339333 if ( File . Exists ( functionMetadataFile ) )
340334 {
341335 var functionMetadataFileContent = FileSystemHelpers . ReadAllTextFromFile ( functionMetadataFile ) ;
342336 var functionMetadata = JsonConvert . DeserializeObject < FunctionMetadata > ( functionMetadataFileContent ) ;
343- isPrecompiled = isPrecompiled || ( functionMetadata ? . ScriptFile ? . EndsWith ( ".dll" ) != null && functionMetadata . ScriptFile . EndsWith ( ".dll" ) ) ;
337+ string extension = Path . GetExtension ( functionMetadata ? . ScriptFile ) . ToLowerInvariant ( ) . TrimStart ( '.' ) ;
338+ isPrecompiled = isPrecompiled || ( ! string . IsNullOrEmpty ( extension ) && extension == "dll" ) ;
344339 }
345340 if ( isPrecompiled )
346341 {
0 commit comments