Skip to content

Commit

Permalink
allowing extensions.json in the root path (Azure#6889)
Browse files Browse the repository at this point in the history
  • Loading branch information
brettsam authored Nov 12, 2020
1 parent 325de5b commit 3c3e349
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/WebJobs.Script/DependencyInjection/ScriptStartupTypeLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Type[] GetStartupTypes()

public async Task<IEnumerable<Type>> GetExtensionsStartupTypesAsync()
{
string binPath;
string extensionsPath;
FunctionAssemblyLoadContext.ResetSharedContext();
var functionMetadataCollection = _functionMetadataManager.GetFunctionMetadata(forceRefresh: true, includeCustomProviders: false);
HashSet<string> bindingsSet = null;
Expand All @@ -89,21 +89,29 @@ public async Task<IEnumerable<Type>> GetExtensionsStartupTypesAsync()
bool isLegacyExtensionBundle = _extensionBundleManager.IsLegacyExtensionBundle();
if (bundleConfigured && (!isPrecompiledFunctionApp || _extensionBundleManager.IsLegacyExtensionBundle()))
{
binPath = await _extensionBundleManager.GetExtensionBundleBinPathAsync();
if (string.IsNullOrEmpty(binPath))
extensionsPath = await _extensionBundleManager.GetExtensionBundleBinPathAsync();
if (string.IsNullOrEmpty(extensionsPath))
{
_logger.ScriptStartUpErrorLoadingExtensionBundle();
return new Type[0];
}
_logger.ScriptStartUpLoadingExtensionBundle(binPath);
_logger.ScriptStartUpLoadingExtensionBundle(extensionsPath);
}
else
{
binPath = Path.Combine(_rootScriptPath, "bin");
_logger.ScriptStartNotLoadingExtensionBundle(binPath, bundleConfigured, isPrecompiledFunctionApp, isLegacyExtensionBundle);
extensionsPath = Path.Combine(_rootScriptPath, "bin");

if (!File.Exists(Path.Combine(extensionsPath, ScriptConstants.ExtensionsMetadataFileName)) &&
File.Exists(Path.Combine(_rootScriptPath, ScriptConstants.ExtensionsMetadataFileName)))
{
// As a fallback, allow extensions.json in the root path.
extensionsPath = _rootScriptPath;
}

_logger.ScriptStartNotLoadingExtensionBundle(extensionsPath, bundleConfigured, isPrecompiledFunctionApp, isLegacyExtensionBundle);
}

string metadataFilePath = Path.Combine(binPath, ScriptConstants.ExtensionsMetadataFileName);
string metadataFilePath = Path.Combine(extensionsPath, ScriptConstants.ExtensionsMetadataFileName);

// parse the extensions file to get declared startup extensions
ExtensionReference[] extensionItems = ParseExtensions(metadataFilePath);
Expand Down Expand Up @@ -138,7 +146,7 @@ public async Task<IEnumerable<Type>> GetExtensionsStartupTypesAsync()
var hintUri = new Uri(path, UriKind.RelativeOrAbsolute);
if (!hintUri.IsAbsoluteUri)
{
path = Path.Combine(binPath, path);
path = Path.Combine(extensionsPath, path);
}

if (File.Exists(path))
Expand Down

0 comments on commit 3c3e349

Please sign in to comment.