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.



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

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

Instance Method Details

#build(configuration) ⇒ Object



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

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

#clean(configuration) ⇒ Object



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

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

  remove_obj_directory
end

#framework_versionObject



178
179
180
181
182
183
184
185
186
187
# File 'lib/bozo/compilers/msbuild.rb', line 178

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



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

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



211
212
213
# File 'lib/bozo/compilers/msbuild.rb', line 211

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

#windowsize_path(path) ⇒ Object



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

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