Skip to content

Commit

Permalink
Set the inproc net8 executable name based on operating system. (#3730)
Browse files Browse the repository at this point in the history
  • Loading branch information
kshyju authored Jun 27, 2024
1 parent 71bd6af commit 2b6ba6e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/Azure.Functions.Cli/Actions/HostActions/StartHostAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ internal class StartHostAction : BaseAction
private const int DefaultPort = 7071;
private const int DefaultTimeout = 20;
private const string Net6FrameworkDescriptionPrefix = ".NET 6.0";
private const string WindowsExecutableName = "func.exe";
private const string LinuxExecutableName = "func";
private const string InProc8DirectoryName = "in-proc8";
private readonly ISecretsManager _secretsManager;
private readonly IProcessManager _processManager;
private IConfigurationRoot _hostJsonConfig;
Expand Down Expand Up @@ -472,7 +475,8 @@ public override async Task RunAsync()
// Checking if in Limelight - it should have a `AzureDevSessionsRemoteHostName` value in local.settings.json.
var forwardedHttpUrl = _secretsManager.GetSecrets().FirstOrDefault(
s => s.Key.Equals(Constants.AzureDevSessionsRemoteHostName, StringComparison.OrdinalIgnoreCase)).Value;
if (forwardedHttpUrl != null){
if (forwardedHttpUrl != null)
{
var baseUrl = forwardedHttpUrl.Replace(Constants.AzureDevSessionsPortSuffixPlaceholder, Port.ToString(), StringComparison.OrdinalIgnoreCase);
baseUri = new Uri(baseUrl);
}
Expand All @@ -486,6 +490,14 @@ public override async Task RunAsync()
await runTask;
}

private static string GetInProcNet8ExecutablePath()
{
var funcExecutableDirectory = Path.GetDirectoryName(typeof(StartHostAction).Assembly.Location)!;
var executableName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? WindowsExecutableName : LinuxExecutableName;

return Path.Combine(funcExecutableDirectory, InProc8DirectoryName, executableName);
}

private Task StartInProc8AsChildProcessAsync()
{
if (VerboseLogging == true)
Expand All @@ -495,8 +507,8 @@ private Task StartInProc8AsChildProcessAsync()

var commandLineArguments = string.Join(" ", Environment.GetCommandLineArgs().Skip(1));
var tcs = new TaskCompletionSource();
var funcExecutableDirectory = Path.GetDirectoryName(typeof(StartHostAction).Assembly.Location)!;
var inProc8FuncExecutablePath = Path.Combine(funcExecutableDirectory, "in-proc8", "func.exe");

var inProc8FuncExecutablePath = GetInProcNet8ExecutablePath();

EnsureNet8FuncExecutablePresent(inProc8FuncExecutablePath);

Expand Down

0 comments on commit 2b6ba6e

Please sign in to comment.