Albacore
Albacore copied to clipboard
ZipDirectory needs to be able to remove root directories
At the moment you can remove all the directories when zipping, however you also need to be able to specify just certain directories to remove:
For example, I want all the contents of InstallerTemp to be included, but I don't want InstallerTemp to be my top level directory in the zip:
zip = ZipDirectory.new
zip.output_path = "xunit.installer/Templates"
zip.output_file = "MVC1-CS-VS2008.zip"
zip.flatten_zip = false
zip.directories_to_zip =["InstallerTemp"]
zip.package
Currently, I uses this trick:
zip a folder and all its subitems (including subfolders)
def zip_folder(folder, zipfile) ZipFile.open(zipfile, 'w') do |zipfile| zipfile.add_folder(folder, false) end end
Zip::ZipFile.class_eval do def add_folder(folder, preserveFolderName=true) Dir[folder + "//."].each do |file_path| file_name = file_path file_name = file_path.sub(File.join(folder, '/'),'') unless preserveFolderName == true add(file_name, file_path) end end end
and use it like this: zip_folder "InstallerTemp", "xunit.installer/Templates/MVC1-CS-VS2008.zip"
This is not clean, but does the job. This may be added to the zip task