Class: MSBuild

Inherits:
Object
  • Object
show all
Includes:
Albacore::RunCommand, Albacore::Task, Configuration::MSBuild
Defined in:
lib/albacore/msbuild.rb

Instance Attribute Summary collapse

Attributes included from Logging

#current_log_device, #logger

Attributes included from Albacore::RunCommand

#command, #working_directory

Instance Method Summary collapse

Methods included from Configuration::MSBuild

included, #msbuild, msbuildconfig, #use

Methods included from Configuration::NetVersion

#get_net_version, #win_dir

Methods included from Failure

#fail_with_message

Methods included from Logging

#create_logger, #log_device=, #log_level, #log_level=

Methods included from Albacore::Configuration

included

Methods included from Albacore::RunCommand

#get_command, #run_command

Methods included from AttrMethods

#attr_array, #attr_hash

Methods included from Albacore::Task

clean_dirname, create_rake_task, include_config, included

Methods included from UpdateAttributes

#<<, #update_attributes

Methods included from YAMLConfig

#configure, #load_config_by_task_name

Constructor Details

#initializeMSBuild

Returns a new instance of MSBuild.



13
14
15
16
# File 'lib/albacore/msbuild.rb', line 13

def initialize
  super()
  update_attributes msbuild.to_hash
end

Instance Attribute Details

#loggermoduleObject

Returns the value of attribute loggermodule.



9
10
11
# File 'lib/albacore/msbuild.rb', line 9

def loggermodule
  @loggermodule
end

#max_cpu_countObject

Returns the value of attribute max_cpu_count.



9
10
11
# File 'lib/albacore/msbuild.rb', line 9

def max_cpu_count
  @max_cpu_count
end

#solutionObject

Returns the value of attribute solution.



9
10
11
# File 'lib/albacore/msbuild.rb', line 9

def solution
  @solution
end

#verbosityObject

Returns the value of attribute verbosity.



9
10
11
# File 'lib/albacore/msbuild.rb', line 9

def verbosity
  @verbosity
end

Instance Method Details

#build_propertiesObject



55
56
57
58
59
60
61
# File 'lib/albacore/msbuild.rb', line 55

def build_properties
  option_text = []
  @properties.each do |key, value|
    option_text << "/p:#{key}\=\"#{value}\""
  end
  option_text.join(" ")
end

#build_solution(solution) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/albacore/msbuild.rb', line 26

def build_solution(solution)
  check_solution solution
  
  command_parameters = []
  command_parameters << "\"#{solution}\""
  command_parameters << "\"/verbosity:#{@verbosity}\"" if @verbosity != nil
  command_parameters << "\"/logger:#{@loggermodule}\"" if @loggermodule != nil
  command_parameters << "\"/maxcpucount:#{@max_cpu_count}\"" if @max_cpu_count != nil
  command_parameters << "\"/nologo\"" if @nologo
  command_parameters << build_properties if @properties != nil
  command_parameters << build_switches if @other_switches != nil
  command_parameters << "\"/target:#{build_targets}\"" if @targets != nil
  
  result = run_command "MSBuild", command_parameters.join(" ")
  
  failure_message = 'MSBuild Failed. See Build Log For Detail'
  fail_with_message failure_message if !result
end

#build_switchesObject



63
64
65
66
67
68
69
# File 'lib/albacore/msbuild.rb', line 63

def build_switches
  switch_text = []
  @other_switches.each do |key, value|
    switch_text << print_switch(key, value)
  end
  switch_text.join(" ")
end

#build_targetsObject



51
52
53
# File 'lib/albacore/msbuild.rb', line 51

def build_targets
  @targets.join ";"
end

#check_solution(file) ⇒ Object



45
46
47
48
49
# File 'lib/albacore/msbuild.rb', line 45

def check_solution(file)
  return if file
  msg = 'solution cannot be nil'
  fail_with_message msg
end

#executeObject



18
19
20
# File 'lib/albacore/msbuild.rb', line 18

def execute
  build_solution(@solution)
end

#nologoObject



22
23
24
# File 'lib/albacore/msbuild.rb', line 22

def 
  @nologo = true     
end


71
72
73
# File 'lib/albacore/msbuild.rb', line 71

def print_switch(key, value)
  pure_switch?(value) ? "/#{key}" : "/#{key}:\"#{value}\""
end

#pure_switch?(value) ⇒ Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/albacore/msbuild.rb', line 75

def pure_switch?(value)
  value.is_a?(TrueClass) || value == :true
end