public static IPackage BuildPackage(PackageBuilder builder, IFileSystem fileSystem, string outputPath = null) { ExcludeFiles(builder.Files); // Track if the package file was already present on disk bool isExistingPackage = fileSystem.file_exists(outputPath); try { using (Stream stream = fileSystem.create_file(outputPath)) { // Truncate if needed, as Mono fails to truncate if (stream.Length > 0) { stream.SetLength(0); } builder.Save(stream); } } catch { if (!isExistingPackage && fileSystem.file_exists(outputPath)) { fileSystem.delete_file(outputPath); } throw; } return(new OptimizedZipPackage(outputPath)); }
public static IPackage BuildPackage(PackageBuilder builder, IFileSystem fileSystem, string outputPath = null) { ExcludeFiles(builder.Files); // Track if the package file was already present on disk bool isExistingPackage = fileSystem.file_exists(outputPath); try { using (Stream stream = fileSystem.create_file(outputPath)) { builder.Save(stream); } } catch { if (!isExistingPackage && fileSystem.file_exists(outputPath)) { fileSystem.delete_file(outputPath); } throw; } return new OptimizedZipPackage(outputPath); }