in src/Cli/func/Actions/LocalActions/PackAction.cs [65:121]
public override async Task RunAsync()
{
var functionAppRoot = string.IsNullOrEmpty(FolderName)
? Path.Combine(Environment.CurrentDirectory, FolderName)
: ScriptHostHelpers.GetFunctionAppRootDirectory(Environment.CurrentDirectory);
string outputPath;
if (string.IsNullOrEmpty(OutputPath))
{
outputPath = Path.Combine(Environment.CurrentDirectory, $"{Path.GetFileName(functionAppRoot)}");
}
else
{
outputPath = Path.Combine(Environment.CurrentDirectory, OutputPath);
if (FileSystemHelpers.DirectoryExists(outputPath))
{
outputPath = Path.Combine(outputPath, $"{Path.GetFileName(functionAppRoot)}");
}
}
if (!FileSystemHelpers.FileExists(Path.Combine(functionAppRoot, ScriptConstants.HostMetadataFileName)))
{
throw new CliException($"Can't find {Path.Combine(functionAppRoot, ScriptConstants.HostMetadataFileName)}");
}
var workerRuntime = WorkerRuntimeLanguageHelper.GetCurrentWorkerRuntimeLanguage(_secretsManager);
outputPath += Squashfs ? ".squashfs" : ".zip";
if (FileSystemHelpers.FileExists(outputPath))
{
ColoredConsole.WriteLine($"Deleting the old package {outputPath}");
try
{
FileSystemHelpers.FileDelete(outputPath);
}
catch (Exception)
{
throw new CliException($"Could not delete {outputPath}");
}
}
// Restore all valid extensions
var installExtensionAction = new InstallExtensionAction(_secretsManager, false);
await installExtensionAction.RunAsync();
bool useGoZip = EnvironmentHelper.GetEnvironmentVariableAsBool(Constants.UseGoZip);
TelemetryHelpers.AddCommandEventToDictionary(TelemetryCommandEvents, "UseGoZip", useGoZip.ToString());
var stream = await ZipHelper.GetAppZipFile(functionAppRoot, BuildNativeDeps, noBuild: false, buildOption: BuildOption.Default, additionalPackages: AdditionalPackages);
if (Squashfs)
{
stream = await PythonHelpers.ZipToSquashfsStream(stream);
}
ColoredConsole.WriteLine($"Creating a new package {outputPath}");
await FileSystemHelpers.WriteToFile(outputPath, stream);
}