Class: MSBuildRunner

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

Class Method Summary collapse

Class Method Details

.compile(attributes) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/msbuild.rb', line 60

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", "nr:False"]
	attributes[:extraSwitches] << "maxcpucount:2" unless Platform.is_nix

	self.runProjFile(attributes);
end

.runProjFile(attributes) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/msbuild.rb', line 73

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