Class: Nbuild::MSBuildCmd

Inherits:
Cmd
  • Object
show all
Defined in:
lib/nbuild/msbuild_cmd.rb

Instance Method Summary collapse

Methods inherited from Cmd

#execute, #execute_in

Constructor Details

#initialize(params = {}) ⇒ MSBuildCmd

Returns a new instance of MSBuildCmd.



5
6
7
8
9
10
11
# File 'lib/nbuild/msbuild_cmd.rb', line 5

def initialize params={}
  @params = params
  version = params.delete(:framework_version)
  version ||= '3.5'
  path = ENV['MS_NET_FRAMEWORK_HOME'] || 'C:\WINDOWS\Microsoft.NET\Framework'
  @path = "#{path}\\v#{version}"
end

Instance Method Details

#commandObject



13
14
15
16
17
18
19
20
21
# File 'lib/nbuild/msbuild_cmd.rb', line 13

def command
  p = @params.dup
  project = p.delete(:project)
  raise 'msbuild: a project or solution parameter is required' unless project
  targets = p.delete(:targets)
  t = "/t:#{targets.join(';')}" if targets
  properties = p.map {|k,v| "/p:#{k}=#{v}"}
  "\"#{@path}\\msbuild.exe\" #{project} #{t} #{properties.join(' ')}"
end