Skip to content

Instantly share code, notes, and snippets.

@nrk
Created January 23, 2009 15:38
Show Gist options
  • Save nrk/51046 to your computer and use it in GitHub Desktop.
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
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