Adding latest AzPSModulesPath to PSModulePath for private preview (#133)

This commit is contained in:
SatishRanjan 2019-01-23 11:47:38 -08:00 коммит произвёл Dongbo Wang
Родитель 9b8c27fd72
Коммит 2cf1ff922c
2 изменённых файлов: 9 добавлений и 2 удалений

Просмотреть файл

@ -7,7 +7,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Management.Automation;
using Microsoft.Azure.WebJobs.Script.Grpc.Messages;
namespace Microsoft.Azure.Functions.PowerShellWorker
@ -18,6 +18,8 @@ namespace Microsoft.Azure.Functions.PowerShellWorker
internal class FunctionLoader
{
private readonly Dictionary<string, AzFunctionInfo> _loadedFunctions = new Dictionary<string, AzFunctionInfo>();
private const string LatestAzModulePath = @"D:\Program Files (x86)\ManagedDependencies\PowerShell\AzPSModules\1.0.0";
private const string AzureWebsiteInstanceId = "WEBSITE_INSTANCE_ID";
internal static string FunctionAppRootPath { get; private set; }
internal static string FunctionAppProfilePath { get; private set; }
@ -57,6 +59,11 @@ namespace Microsoft.Azure.Functions.PowerShellWorker
var appLevelModulesPath = Path.Join(FunctionAppRootPath, "Modules");
var workerLevelModulesPath = Path.Join(AppDomain.CurrentDomain.BaseDirectory, "Modules");
FunctionModulePath = $"{appLevelModulesPath}{Path.PathSeparator}{workerLevelModulesPath}";
if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable(AzureWebsiteInstanceId))
&& Platform.IsWindows)
{
FunctionModulePath = $"{FunctionModulePath}{Path.PathSeparator}{LatestAzModulePath}";
}
// Resolve the FunctionApp profile path
var options = new EnumerationOptions { MatchCasing = MatchCasing.CaseInsensitive };

Просмотреть файл

@ -37,7 +37,7 @@ namespace Microsoft.Azure.Functions.PowerShellWorker.Test
}
};
FunctionLoadRequest = new FunctionLoadRequest {FunctionId = "FunctionId", Metadata = RpcFunctionMetadata};
FunctionLoadRequest = new FunctionLoadRequest { FunctionId = "FunctionId", Metadata = RpcFunctionMetadata };
FunctionLoader.SetupWellKnownPaths(FunctionLoadRequest);
}