Skip to content

Instantly share code, notes, and snippets.

@jimholmes
Created February 8, 2011 21:20
Show Gist options
  • Save jimholmes/817269 to your computer and use it in GitHub Desktop.
Save jimholmes/817269 to your computer and use it in GitHub Desktop.
require 'optparse'
def process_command_args
$options = {}
opts = OptionParser.new
opts.banner = "Usage: build [options]"
opts.on( "-r", "--release", "release configuration" ) do
$options[:releaseconfig] = true
end
opts.on( "-d", "--debug", "debug config" ) do
$options[:debugconfig] = true
end
opts.on( "-c", "--clean", "clean build" ) do
$options[:clean] = true
end
opts.on("-h", "--help", "Display this screen") do
puts opts
exit
end
opts.parse(ARGV)
if ($options[:releaseconfig].nil? && $options[:debugconfig].nil?)
puts "Red pill or blue, your choice. Try -d or -r.ac"
puts opts
exit
end
if ($options[:releaseconfig] && $options[:debugconfig])
puts "Make up your mind: release OR debug, not both"
puts opts
exit
end
end
def do_the_work
if $options[:releaseconfig]
$config= "release"
end
if $options[:debugconfig]
$config = "debug"
end
$sln = Dir.glob("*.sln")
if ($sln.length > 1)
puts "More than one .sln file here. Can't figure it out, bailing."
exit
end
$command = "msbuild " + $sln[0] + " /p:configuration=" + $config
if $options[:clean]
$command += " /t:clean"
end
system($command)
end
process_command_args()
do_the_work()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment