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.



155
156
157
158
# File 'lib/bozo/compilers/msbuild.rb', line 155

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

Instance Method Details

#build(configuration) ⇒ Object



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

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

#clean(configuration) ⇒ Object



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

def clean(configuration)
  config = configuration.dup
  config.delete(:max_cores)
  config[:targets] = [:clean]
  args = generate_args config
  execute_command :msbuild, args

  remove_obj_directory
end

#framework_versionObject



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

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



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

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 << "/p:StyleCopEnabled=false" if config[:without_stylecop]
  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



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

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

#windowsize_path(path) ⇒ Object



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

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