Created
January 23, 2009 15:38
-
-
Save nrk/51046 to your computer and use it in GitHub Desktop.
Quickly-hacked script to remove all the signing stuff from the IronRuby VS solution
This file contains hidden or 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
require 'rexml/document' | |
require 'ftools' | |
include REXML | |
# ---------------------------------------------------------------------------------------- # | |
GIT_ROOT = 'C:/Development/ironruby' | |
SUPPORT_DIR = File.join(GIT_ROOT, 'Merlin/Main/Support') | |
# ---------------------------------------------------------------------------------------- # | |
def load_xml(file) | |
Document.new(IO.readlines(file).to_s) | |
end | |
def save_xml(file, xml_doc, backup = false) | |
File.rename(file, "#{file}.backup") if backup | |
File.open(file, 'w') { |fp| xml_doc.write(fp) } | |
end | |
def copy_file_in_support(file, overwrite = false) | |
Dir.mkdir(SUPPORT_DIR) unless File.exist?(SUPPORT_DIR) | |
destination = File.join(SUPPORT_DIR, File.basename(file)) | |
File.delete(destination) if overwrite and File.exist?(destination) | |
File.copy(file, destination) | |
end | |
def rewrite_appconfig(appconfig_file, backup = true) | |
publickey_match = /31bf3856ad364e35/ | |
appconfig_doc = load_xml(appconfig_file) | |
section = XPath.first(appconfig_doc, '/configuration/configSections/section') | |
language = XPath.first(appconfig_doc, '/configuration/microsoft.scripting/languages/language[@names=\'IronRuby;Ruby;rb\']') | |
section.attributes['type'].gsub!(publickey_match, 'null') | |
language.attributes['type'].gsub!(publickey_match, 'null') | |
save_xml(appconfig_file, appconfig_doc, backup) | |
end | |
def rewrite_csprojs(csproj_files, backup = true) | |
csproj_files.each do |csproj_file| | |
csproj_doc = load_xml(csproj_file) | |
XPath.each(csproj_doc, '//Project/PropertyGroup/DefineConstants') do |node| | |
node.text = node.text.gsub(/SIGNED;?/, '') | |
end | |
['DelaySign', 'AssemblyOriginatorKeyFile', 'SignAssembly'].each do |node_name| | |
csproj_doc.elements.delete_all("//Project/PropertyGroup/#{node_name}") | |
end | |
save_xml(csproj_file, csproj_doc, backup) | |
end | |
end | |
# ---------------------------------------------------------------------------------------- # | |
copy_file_in_support(File.join(GIT_ROOT, 'Merlin/Main/Languages/Ruby/SpecSharp.targets')) | |
rewrite_appconfig(File.join(GIT_ROOT, 'Merlin/Main/App.config')) | |
rewrite_csprojs(Dir[File.join(GIT_ROOT, '**/*.csproj')]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment