Created
April 2, 2013 01:26
-
-
Save aktowns/5289236 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# Quick and dirty script to fix up .fsproj build orders | |
# to compile under xbuild when enabled in xamarin studio | |
# | |
# this relies on a propper build order set the normal way under | |
# project options -> general -> build order. Output should be something like | |
# | |
# $ fixorder.rb gitopc/gitopc.fsproj | |
# Make sure you have set a valid build order in 'Project options -> General -> Build order' before running this script | |
# Press enter to continue, Ctrl+C to abort. | |
# | |
# Changing build order to: | |
# 0: AssemblyInfo.fs => AssemblyInfo.fs | |
# 1: Program.fs => Logging.fs | |
# 2: PrivateKey.fs => PrivateKey.fs | |
# 3: CDNUtils.fs => EmailUtils.fs | |
# 4: Logging.fs => OBundleUtils.fs | |
# 5: EmailUtils.fs => CDNUtils.fs | |
# 6: OBundleUtils.fs => Program.fs | |
# Press enter to continue, Ctrl+C to abort. | |
# | |
# Backing up gitopc/gitopc.fsproj to gitopc/gitopc.fsproj.backup | |
# Build order re-ordered! | |
require 'nokogiri' | |
require 'fileutils' | |
filename = ARGV[0] | |
puts "Make sure you have set a valid build order in 'Project options -> General -> Build order' before running this script" | |
puts "Press enter to continue, Ctrl+C to abort." | |
_ = STDIN.readline | |
fp = File.open(filename, "r") | |
doc = Nokogiri::XML(fp) | |
trueBuildOrder = doc.search('Project/PropertyGroup/BuildOrder/BuildOrder/String').map(&:text) | |
toChangeBuildOrder = doc.search('Project/ItemGroup/Compile') | |
raise "Build order mismatch, have you set the build order in options?" if trueBuildOrder.length != toChangeBuildOrder.length | |
puts "Changing build order to:" | |
toChangeBuildOrder.to_a.each_index do |i| | |
puts "#{i}: #{toChangeBuildOrder[i]["Include"]} => #{trueBuildOrder[i]}" | |
toChangeBuildOrder[i]["Include"] = trueBuildOrder[i] | |
end | |
fp.close | |
puts "Press enter to continue, Ctrl+C to abort." | |
_ = STDIN.readline | |
puts "Backing up #{filename} to #{filename}.backup" | |
FileUtils.cp filename, "#{filename}.backup" | |
File.open(filename, "w") {|fp| fp.write doc} | |
puts "Build order re-ordered!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment