I am trying to archive rake assembly artifacts using Albacore ZipTask . The solution I create has three projects that have artifacts that need to be encrypted separately, but only the ASP.NET MVC project will be mentioned here. Here's the directory structure of the solution:
rakefile.rb solution.sln src/ (other projects that are not relevant) website/ (various folders I don't want included in the artifacts) bin/ Content/ Scripts/ Views/ Default.aspx Global.asax web.config
First I wrote this task:
website_directory = File.join '.', 'src', 'website' website_project_name = 'website' zip :zip => [ :run_unit_tests, :less ] do |zip| zip.directories_to_zip = [ 'bin', 'Content', 'Scripts', 'Views' ].map{ |folder| File.join website_directory, folder } zip.additional_files = [ 'Default.aspx', 'favicon.ico', 'Global.asax', 'web.config'].map{ |file| File.join website_directory, file } zip.output_file = get_output_file_name zip.output_path = get_artifacts_output_path website_project_name end
The problem is that the result of this task is a zip file containing the contents of these folders, not the folders themselves, which is clearly undesirable.
Then I tried to flip the flatten_zip field to false (this is not a document field, but you can find it in the source ). This created a zip code containing the folders above, but at the bottom of the entire folder hierarchy ./src/website/ . I want the above folders to be in the zip root directory so as not to work.
So my next shot was using exclusions , which is also not documented:
zip :zip => [ :run_unit_tests, :less ] do |zip| zip.directories_to_zip website_directory zip.exclusions = [ /.git/, /.+\.cs/, /App_Data/, /Attributes/, /AutoMapper/, /Controllers/, /Diagrams/, /Extensions/, /Filters/, /Helpers/, /Models/, /obj/, /Properties/, /StructureMap/, /Templates/, /CompTracker.Web.csproj/, /Default.aspx.cs/, /Global.asax.cs/, /Publish.xml/, /pdb/ ] zip.output_file = get_output_file_name zip.output_path = get_artifacts_output_path website_project_name end
This worked for me, but when I recently added /AutoMapper/ and /StructureMap/ to the exclusions array, it also caused, of course, also that AutoMapper.dll and StructureMap.dll were excluded from the bin folder.
How can I change any of the above tasks to have only the folders and files that I want in the root of my zip?