Hi everyone,
I'm trying to zip up the artifacts of a rake build, using Albacore's ZipTask. The solution I'm building has three projects that have artifacts that need to be zipped up individually, 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
At 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
Problem is, the output of this task is a zip file containing the contents of those folders, not the folders themselves, which is obviously undesirable.
Next, I tried flipping the flatten_zip
field to false (which is not a documented field but you can find it in the source). This produced a zip that contained the above folders, but at the bottom of the whole ./src/website/
folder hierarchy. I want the above folders at the root of the zip, so that's not working either.
So my next shot was this, 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 AutoMapper.dll and StructureMap.dll to (of course) also be excluded from the bin folder.
So, how should I edit any of the above tasks to have only the folders and files I want at the root of my zip?
My Ruby fu is pretty weak so I'm sure I'm missing something I could be doing in that regard!
Thanks a lot. :)