in src/Cli/func/Actions/AzureActions/PublishFunctionAppAction.cs [149:252]
public override async Task RunAsync()
{
// Get function app
var functionApp = await AzureHelper.GetFunctionApp(FunctionAppName, AccessToken, ManagementURL, Slot, Subscription);
if (!functionApp.IsLinux && PublishBuildOption == BuildOption.Container)
{
throw new CliException($"--build {PublishBuildOption} is not supported for Windows Function Apps.");
}
if (!functionApp.IsLinux && functionApp.IsElasticPremium && PublishBuildOption == BuildOption.Remote)
{
throw new CliException($"--build {PublishBuildOption} is not supported for Windows Elastic Premium Function Apps.");
}
// Get the GitIgnoreParser from the functionApp root
var functionAppRoot = ScriptHostHelpers.GetFunctionAppRootDirectory(Environment.CurrentDirectory);
var ignoreParser = PublishHelper.GetIgnoreParser(functionAppRoot);
// Get the WorkerRuntime
var workerRuntime = GlobalCoreToolsSettings.CurrentWorkerRuntime;
// Determine the appropriate default targetFramework
// TODO: Include proper steps for publishing a .NET Framework 4.8 application
if (workerRuntime == WorkerRuntime.DotnetIsolated)
{
string projectFilePath = ProjectHelpers.FindProjectFile(functionAppRoot);
if (projectFilePath != null)
{
var targetFramework = await DotnetHelpers.DetermineTargetFramework(Path.GetDirectoryName(projectFilePath));
var majorDotnetVersion = StacksApiHelper.GetMajorDotnetVersionFromDotnetVersionInProject(targetFramework);
if (majorDotnetVersion != null)
{
// Get Stacks
var stacks = await AzureHelper.GetFunctionsStacks(AccessToken, ManagementURL);
var runtimeSettings = stacks.GetRuntimeSettings(majorDotnetVersion.Value, out bool isLTS);
ShowEolMessage(stacks, runtimeSettings, majorDotnetVersion.Value);
// This is for future proofing with stacks API for future dotnet versions.
if (runtimeSettings != null &&
(runtimeSettings.IsDeprecated == null || runtimeSettings.IsDeprecated == false) &&
(runtimeSettings.IsDeprecatedForRuntime == null || runtimeSettings.IsDeprecatedForRuntime == false))
{
_requiredNetFrameworkVersion = $"{majorDotnetVersion}.0";
}
}
else if (targetFramework.Equals("net8.0", StringComparison.InvariantCultureIgnoreCase))
{
_requiredNetFrameworkVersion = "8.0";
}
else
{
ColoredConsole.WriteLine(WarningColor(
$"Can not interpret target framework '{targetFramework}', assuming framework '{_requiredNetFrameworkVersion}'"));
}
}
// We do not change the default targetFramework if no .csproj file is found
}
// Check for any additional conditions or app settings that need to change
// before starting any of the publish activity.
var additionalAppSettings = await ValidateFunctionAppPublish(functionApp, workerRuntime, functionAppRoot);
// Update build option
PublishBuildOption = PublishHelper.ResolveBuildOption(PublishBuildOption, workerRuntime, functionApp, BuildNativeDeps, NoBuild);
bool isNonCsxDotnetRuntime = WorkerRuntimeLanguageHelper.IsDotnet(workerRuntime) && !Csx;
if (isNonCsxDotnetRuntime && !NoBuild && PublishBuildOption != BuildOption.Remote)
{
await DotnetHelpers.BuildAndChangeDirectory(Path.Combine("bin", "publish"), DotnetCliParameters);
}
if (!isNonCsxDotnetRuntime)
{
// Restore all valid extensions
var installExtensionAction = new InstallExtensionAction(_secretsManager, false);
await installExtensionAction.RunAsync();
}
if (ListIncludedFiles)
{
InternalListIncludedFiles(ignoreParser);
}
else if (ListIgnoredFiles)
{
InternalListIgnoredFiles(ignoreParser);
}
else
{
if (PublishLocalSettingsOnly)
{
await PublishLocalAppSettings(functionApp, additionalAppSettings);
}
else
{
await PublishFunctionApp(functionApp, ignoreParser, additionalAppSettings);
}
}
}