Class: Rake::Funnel::Support::MSBuild::BuildTool

Inherits:
Object
  • Object
show all
Defined in:
lib/rake/funnel/support/msbuild/build_tool.rb

Class Method Summary collapse

Class Method Details

.findObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rake/funnel/support/msbuild/build_tool.rb', line 7

def find
  return 'xbuild' unless Rake::Win32.windows?

  require 'win32/registry'

  %w(14.0 12.0 4.0 3.5 2.0).collect { |version|
    key = "SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\#{version}"

    begin
      ::Win32::Registry::HKEY_LOCAL_MACHINE.open(key) do |reg|
        candidate = File.join(reg['MSBuildToolsPath'] || '', 'msbuild.exe')
        next candidate if File.exist?(candidate)
      end
    rescue
      next
    end
  }.compact.first
end