Class: MSBuildRunner

Inherits:
Object
  • Object
show all
Defined in:
lib/msbuild.rb

Class Method Summary collapse

Class Method Details

.compile(attributes) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/msbuild.rb', line 36

def self.compile(attributes)
  compileTarget = attributes.fetch(:compilemode, 'debug')
    solutionFile = attributes[:solutionfile]
    
    attributes[:projFile] = solutionFile
    attributes[:properties] ||= []
    attributes[:properties] << "Configuration=#{compileTarget}"
    attributes[:extraSwitches] = ["v:m", "t:rebuild"]
  attributes[:extraSwitches] << "maxcpucount:2" unless Platform.is_nix

     self.runProjFile(attributes);
end

.runProjFile(attributes) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/msbuild.rb', line 49

def self.runProjFile(attributes)
  version = attributes.fetch(:clrversion, 'v4.0.30319')
  compileTarget = attributes.fetch(:compilemode, 'debug')
    projFile = attributes[:projFile]
  
   if Platform.is_nix
     msbuildFile = `which xbuild`.chop
     attributes[:properties] << "TargetFrameworkProfile="""""
   else
    frameworkDir = File.join(ENV['windir'].dup, 'Microsoft.NET', 'Framework', version)
    msbuildFile = File.join(frameworkDir, 'msbuild.exe')
  end

   properties = attributes.fetch(:properties, [])
  
  switchesValue = ""
  
  properties.each do |prop|
    switchesValue += " /property:#{prop}"
  end  
  
  extraSwitches = attributes.fetch(:extraSwitches, []) 
  
  extraSwitches.each do |switch|
    switchesValue += " /#{switch}"
  end  
  
  targets = attributes.fetch(:targets, [])
  targetsValue = ""
  targets.each do |target|
    targetsValue += " /t:#{target}"
  end
  
  sh "#{msbuildFile} #{projFile} #{targetsValue} #{switchesValue}"
end