So, if I read your question correctly, you have two projects each with a separate VERSION
file in some project-specific sub-folder. Something like this...
my-project/
source/
projectA/
Properties/
AssemblyInfo.cs
VERSION
projectB/
Properties/
AssemblyInfo.cs
VERSION
And you want to a Rake/Albacore task that will apply the correct version to each project. The way you have your first task structured, you're only creating one task and you're overwriting the properties assigned to it with that loop!
assemblyinfo :assemblyinfo do |asm| #=> one :version task
projects.each do |proj| #=> many iterations
# ... assignment ... #=> overwriting properties
end
end
The second task definition, the "slight tweak", is actually kind-of accidentally working. You're defining the entire task each time through the projects loop, but with the same name. This is where you're hitting a little-known Rake feature that you might not have been aware of... tasks with the same name are appended to one another. So, you're actually making 2 tasks with 1 name with different bodies.
projects.each do |proj| #=> many iterations
assemblyinfo :assemblyinfo do |asm| #=> many tasks mapped to the same name
# ... assignment ... #=> separate properties
end
end
To make things more clear, I recommend a task definition where every assemblyinfo
task gets it's own unique name, then you construct a version
task that's dependent on all of them.
projects.each do |proj|
name = File.join(proj, "Properties/AssemblyInfo.cs")
bumper_file = File.join(proj, "VERSION")
assemblyinfo name do |asm|
asm.output_file = asm
asm.version = asm.file_version = bumper_version.to_s
asm.product_name = proj
end
end
desc "Version every project in the solution"
task :version => projects.map { |proj| File.join(proj, "Properties/AssemblyInfo.cs") }