Class: Bozo::Compilers::Msbuild

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

Instance Method Summary collapse

Constructor Details

#initializeMsbuild

Returns a new instance of Msbuild.



23
24
25
26
# File 'lib/bozo/compilers/msbuild.rb', line 23

def initialize
  @config = {}
  @exclude_projects = []
end

Instance Method Details

#config_with_defaultsObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/bozo/compilers/msbuild.rb', line 7

def config_with_defaults
  defaults = {
    :version => 'v4.0.30319',
    :framework => 'Framework64',
    :properties => {:configuration => :release},
    :max_cores => nil
  }

  default_targets = [:build]

  config = defaults.merge @config
  config[:targets] = (@targets or default_targets).clone
  config[:websites_as_zip] = false
  config
end

#configurationObject



77
78
79
# File 'lib/bozo/compilers/msbuild.rb', line 77

def configuration
  config_with_defaults
end

#exclude_project(project_name) ⇒ Object



45
46
47
# File 'lib/bozo/compilers/msbuild.rb', line 45

def exclude_project(project_name)
  @exclude_projects << project_name
end

#executeObject



81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/bozo/compilers/msbuild.rb', line 81

def execute
  projects = (project_files('test') | project_files('src')).map { |file| create_project file }
  
  # Clean all the projects first.
  projects.each do |project|
    project.clean configuration
  end

  # Build all the projects so they can utilize each others artifacts.
  projects.each do |project|
    project.build configuration
  end
end

#framework(framework) ⇒ Object



32
33
34
# File 'lib/bozo/compilers/msbuild.rb', line 32

def framework(framework)
  @config[:framework] = framework
end

#max_cores(cores) ⇒ Object

Assign how many cores should be used by msbuild

Parameters:

  • cores (Integer)

    The maximum number of cores to allow msbuild to use



57
58
59
# File 'lib/bozo/compilers/msbuild.rb', line 57

def max_cores(cores)
  @config[:max_cores] = cores
end

#project_files(directory) ⇒ Object



95
96
97
98
# File 'lib/bozo/compilers/msbuild.rb', line 95

def project_files(directory)
  project_file_matcher = File.expand_path(File.join(directory, 'csharp', '**', '*.csproj'))
  Dir[project_file_matcher].select { |p| not @exclude_projects.include?(File.basename p, '.csproj') }
end

#property(args) ⇒ Object Also known as: properties



40
41
42
43
# File 'lib/bozo/compilers/msbuild.rb', line 40

def property(args)
  @config[:properties] ||= {}
  @config[:properties] = @config[:properties].merge(args)
end

#required_toolsObject



100
101
102
# File 'lib/bozo/compilers/msbuild.rb', line 100

def required_tools
  :stylecop unless @config[:without_stylecop]
end

#solution(path) ⇒ Object



36
37
38
# File 'lib/bozo/compilers/msbuild.rb', line 36

def solution(path)
  @config[:solution] = path
end

#target(target) ⇒ Object



63
64
65
66
# File 'lib/bozo/compilers/msbuild.rb', line 63

def target(target)
  @targets ||= []
  @targets << target
end

#to_sObject



68
69
70
71
# File 'lib/bozo/compilers/msbuild.rb', line 68

def to_s
  config = configuration
  "Compile with msbuild #{config[:version]} building #{config[:solution]} with properties #{config[:properties]} for targets #{config[:targets]}"
end

#version(version) ⇒ Object



28
29
30
# File 'lib/bozo/compilers/msbuild.rb', line 28

def version(version)
  @config[:version] = version
end

#websites_as_zip?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/bozo/compilers/msbuild.rb', line 49

def websites_as_zip?
  @config[:websites_as_zip] = true
end

#without_stylecopObject



73
74
75
# File 'lib/bozo/compilers/msbuild.rb', line 73

def without_stylecop
  @config[:without_stylecop] = true
end