Class: Bozo::Compilers::Project

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

Direct Known Subclasses

ClassLibrary, WebProject2008, WebProject2010

Instance Method Summary collapse

Constructor Details

#initialize(project_file, project_name) ⇒ Project

Returns a new instance of Project.



158
159
160
161
# File 'lib/bozo/compilers/msbuild.rb', line 158

def initialize(project_file, project_name)
  @project_file = project_file
  @project_name = project_name
end

Instance Method Details

#build(configuration) ⇒ Object



163
164
165
166
167
# File 'lib/bozo/compilers/msbuild.rb', line 163

def build(configuration)
  populate_config(configuration)
  args = generate_args configuration
  execute_command :msbuild, args
end

#clean(configuration) ⇒ Object



169
170
171
172
173
# File 'lib/bozo/compilers/msbuild.rb', line 169

def clean(configuration)
  configuration[:targets] = [:clean]
  args = generate_args configuration
  execute_command :msbuild, args
end

#framework_versionObject



175
176
177
178
179
180
181
182
183
184
# File 'lib/bozo/compilers/msbuild.rb', line 175

def framework_version
  framework_version = 'unknown'

  File.open(@project_file) do |f|
    framework_version = Nokogiri::XML(f).css('Project PropertyGroup TargetFrameworkVersion').first.content
    framework_version = framework_version.sub('v', 'net').sub('.', '')
  end

  framework_version
end

#generate_args(config) ⇒ Object



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# File 'lib/bozo/compilers/msbuild.rb', line 186

def generate_args(config)
  args = []

  args << File.join(ENV['WINDIR'], 'Microsoft.NET', config[:framework], config[:version], 'msbuild.exe')
  args << '/nologo'
  args << '/verbosity:normal'
  args << '/nodeReuse:false'
  args << "/target:#{config[:targets].map{|t| t.to_s}.join(';')}"
  args << "/maxcpucount" if config[:max_cores].nil? # let msbuild decide how many cores to use
  args << "/maxcpucount:#{config[:max_cores]}" unless config[:max_cores].nil? # specifying the number of cores

  config[:properties].each do |key, value|
    args << "/property:#{key}=\"#{value}\""
  end

  args << "\"#{@project_file}\""
end

#locationObject



208
209
210
# File 'lib/bozo/compilers/msbuild.rb', line 208

def location
  File.expand_path(File.join('temp', 'msbuild', @project_name, framework_version))
end

#windowsize_path(path) ⇒ Object



204
205
206
# File 'lib/bozo/compilers/msbuild.rb', line 204

def windowsize_path(path)
  path.gsub(/\//, '\\')
end