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(); 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); }
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)}.zip"); } else { outputPath = Path.Combine(Environment.CurrentDirectory, OutputPath); if (FileSystemHelpers.DirectoryExists(outputPath)) { outputPath = Path.Combine(outputPath, $"{Path.GetFileName(functionAppRoot)}.zip"); } } if (!FileSystemHelpers.FileExists(Path.Combine(functionAppRoot, ScriptConstants.HostMetadataFileName))) { throw new CliException($"Can't find {Path.Combine(functionAppRoot, ScriptConstants.HostMetadataFileName)}"); } var workerRuntime = WorkerRuntimeLanguageHelper.GetCurrentWorkerRuntimeLanguage(_secretsManager); if (FileSystemHelpers.FileExists(outputPath)) { ColoredConsole.WriteLine($"Deleting the old package {outputPath}"); try { FileSystemHelpers.FileDelete(outputPath); } catch (Exception) { throw new CliException($"Could not delete {outputPath}"); } } var zipStream = await ZipHelper.GetAppZipFile(workerRuntime, functionAppRoot, BuildNativeDeps, additionalPackages : AdditionalPackages); ColoredConsole.WriteLine($"Creating a new package {outputPath}"); await FileSystemHelpers.WriteToFile(outputPath, zipStream); }