Sha256: 39c4f6269674a1c2fc3f601153bfe3f588a05d6561d3e804b223c19412be5b53

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

require "albacore/albacoretask"
require "albacore/config/msbuildconfig"

class MSBuild
  TaskName = :msbuild

  include Albacore::Task
  include Albacore::RunCommand
  include Configuration::MSBuild
  
  attr_reader   :no_logo
  
  attr_accessor :solution, 
                :verbosity, 
                # 'logger' property already exists in parent
                :logger_module 
  
  attr_array    :targets
  
  attr_hash     :properties, 
                :other_switches
  
  def initialize
    @command = "msbuild"
    
    super()
    update_attributes(msbuild.to_hash)
  end
  
  def execute
    unless @solution
      fail_with_message("msbuild requires #solution")
      return
    end

    result = run_command("MSBuild", build_parameters)
    fail_with_message("MSBuild failed, see the build log for more details.") unless result
  end
  
  def build_parameters()
    p = []
    p << "\"#{@solution}\""
    p << "/verbosity:#{@verbosity}" if @verbosity
    p << "/logger:\"#{@logger_module}\"" if @logger_module
    p << "/nologo" if @no_logo
    p << @properties.map { |key, value| "/property:#{key}\=\"#{value}\"" } if @properties
    p << @other_switches.map { |key, value| "/#{key}:\"#{value}\"" } if @other_switches
    p << "/target:\"#{@targets.join(";")}\"" if @targets
    p
  end

  def no_logo
    @no_logo = true
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
albacore-1.0.0 lib/albacore/msbuild.rb
albacore-1.0.0.rc.3 lib/albacore/msbuild.rb