internal async Task ValidateHostRuntimeAsync()

in src/Cli/func/Actions/HostActions/StartHostAction.cs [521:567]


        internal async Task ValidateHostRuntimeAsync(
            WorkerRuntime currentWorkerRuntime,
            Func<Task<bool>> validateDotNet8ProjectEnablement = null)
        {
            validateDotNet8ProjectEnablement ??= IsInProcDotNet8Enabled;

            void ThrowCliException(string suffix)
            {
                throw new CliException($"The runtime argument value provided, '{HostRuntime}', is invalid. {suffix}");
            }

            if (DotnetConstants.ValidRuntimeValues.Contains(HostRuntime, StringComparer.OrdinalIgnoreCase) == false)
            {
                ThrowCliException($"Valid values are '{string.Join("', '", DotnetConstants.ValidRuntimeValues)}'.");
            }

            var isInproc6ArgumentValue = string.Equals(HostRuntime, DotnetConstants.InProc6HostRuntime, StringComparison.OrdinalIgnoreCase);
            var isInproc8ArgumentValue = string.Equals(HostRuntime, DotnetConstants.InProc8HostRuntime, StringComparison.OrdinalIgnoreCase);

            if (currentWorkerRuntime == WorkerRuntime.Dotnet)
            {
                if (isInproc6ArgumentValue)
                {
                    PrintMigrationWarningForDotnet6Inproc();
                }

                if (string.Equals(HostRuntime, "default", StringComparison.OrdinalIgnoreCase))
                {
                    ThrowCliException($"The provided value is only valid for the worker runtime '{WorkerRuntime.DotnetIsolated.GetDisplayString()}'.");
                }

                if (isInproc8ArgumentValue && !await validateDotNet8ProjectEnablement())
                {
                    ThrowCliException($"For the .NET 8 runtime on the in-process model, you must set the '{Constants.InProcDotNet8EnabledSetting}' environment variable to '1'. For more information, see https://aka.ms/azure-functions/dotnet/net8-in-process.");
                }
                else if (isInproc6ArgumentValue && await validateDotNet8ProjectEnablement())
                {
                    ThrowCliException($"For the '{DotnetConstants.InProc6HostRuntime}' runtime, the '{Constants.InProcDotNet8EnabledSetting}' environment variable cannot be be set. See https://aka.ms/azure-functions/dotnet/net8-in-process.");
                }
            }
            else if (isInproc8ArgumentValue || isInproc6ArgumentValue)
            {
                ThrowCliException($"The provided value is only valid for the worker runtime '{WorkerRuntime.Dotnet.GetDisplayString()}'.");
            }

            PrintVerboseForHostSelection(HostRuntime);
        }