lib/rake/funnel/support/msbuild/build_tool.rb in rake-funnel-0.1.0.pre vs lib/rake/funnel/support/msbuild/build_tool.rb in rake-funnel-0.2.0.pre

- old
+ new

@@ -1,28 +1,24 @@ module Rake::Funnel::Support::MSBuild class BuildTool class << self def find - if Rake::Win32.windows? - require 'win32/registry' + return 'xbuild' unless Rake::Win32.windows? - %w{12.0 4.0 3.5 2.0}.collect { |version| - msbuild = nil - key = "SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\#{version}" + require 'win32/registry' - begin - Win32::Registry::HKEY_LOCAL_MACHINE.open(key) do |reg| - candidate = "#{reg['MSBuildToolsPath']}\\msbuild.exe" - msbuild = candidate if File.exists?(candidate) - end - rescue - end + %w(12.0 4.0 3.5 2.0).collect { |version| + key = "SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\#{version}" - msbuild - }.compact.first - else - 'xbuild' - end + begin + Win32::Registry::HKEY_LOCAL_MACHINE.open(key) do |reg| + candidate = File.join(reg['MSBuildToolsPath'] || '', 'msbuild.exe') + next candidate if File.exists?(candidate) + end + rescue + next + end + }.compact.first end end end end