I have been playing around with Rake and Albacore, to see if I can replace our existing MSBuild script that deploys software with something that isn't XML. I have a task that will change the debug value inside a web.config to false. The task takes the directory of the web.config as an argument, but I can't quite figure out the syntax needed to supply this argument in the default task.
require 'albacore'
require 'nokogiri'
deployment_path = "c:\\test-mars-deploy"
task :default => [ :buildMARS, :publishMARS, :updatewebconfig ['c:\\test-mars-deploy']]
msbuild :buildMARS do |msb|
msb.solution = "MARS/MARS.sln"
msb.targets :clean, :build
msb.properties :configuration => :release
end
task :updatewebconfig, :deploypath do |t, args|
deployment_path = #{args[:deploypath]}
webconfig_path = deployment_path + "/Web.config"
f = File.open(webconfig_path, "r+")
doc = Nokogiri::XML(f)
puts "finding attribute"
attribute = doc.xpath("/configuration/system.web/compilation")
attribute.attr("debug","false")
puts attribute.to_xml
f.close()
File.delete(webconfig_path)
fi = File.new(webconfig_path, "w")
fi.write(doc.to_s)
fi.close()
end
msbuild :publishMARS do |msb|
msb.targets :ResolveReferences, :_CopyWebApplication
msb.properties(
:configuration => :release,
:webprojectoutputdir => deployment_path,
:outdir => deployment_path + "/bin/"
)
msb.solution = "MARS/MARS.vbproj"
end
I'm pretty sure there's an easy solution to this, but I can't seem to figure it out!