class Albacore::Build::Config

The configuration class for xbuild and msbuild. MSDN docs at: msdn.microsoft.com/en-us/library/vstudio/ms164311.aspx

Attributes

files[RW]
properties[RW]

any properties you want to set

target[R]

this is the target of the compilation with MsBuild/XBuild

Public Class Methods

new() click to toggle source
# File lib/albacore/task_types/build.rb, line 40
def initialize
  @parameters = Set.new

  w = lambda { |e| CrossPlatformCmd.which(e) ? e : nil }

  @files = []

  @exe = w.call( "msbuild" ) ||
         w.call( "xbuild" )  ||
         heuristic_executable

  debug { "build using '#{@exe}'" }
  set_logging (ENV['DEBUG'] ?
                (ENV['VERBOSE'] ?
                  'detailed' :
                  'normal') :
                'minimal')
end

Public Instance Methods

be_quiet() click to toggle source

Set logging verbosity to quiet

# File lib/albacore/task_types/build.rb, line 142
def be_quiet
  logging = "quiet"
end
clp(param) click to toggle source

Pass the parameters that you specify to the console logger, which displays build information in the console window. You can specify the following parameters:

  • PerformanceSummary. Show the time that's spent in tasks, targets and projects.

  • Summary. Show the error and warning summary at the end.

  • NoSummary. Don't show the error and warning summary at the end.

  • ErrorsOnly. Show only errors.

  • WarningsOnly. Show only warnings.

  • NoItemAndPropertyList. Don't show the list of items and properties that would appear at the start of each project build if the verbosity level is set to diagnostic.

  • ShowCommandLine. Show TaskCommandLineEvent messages.

  • ShowTimestamp. Show the timestamp as a prefix to any message.

  • ShowEventId. Show the event ID for each started event, finished event, and message.

  • ForceNoAlign. Don't align the text to the size of the console buffer.

  • DisableConsoleColor. Use the default console colors for all logging messages.

  • DisableMPLogging. Disable the multiprocessor logging style of output when running in non-multiprocessor mode.

  • EnableMPLogging. Enable the multiprocessor logging style even when running in non-multiprocessor mode. This logging style is on by default.

  • Verbosity. Override the /verbosity setting for this logger.

# File lib/albacore/task_types/build.rb, line 137
def clp param
  update_array_prop "consoleloggerparameters", method(:make_clp), :clp, param
end
params_for_file(file) click to toggle source
# File lib/albacore/task_types/build.rb, line 151
def params_for_file file
  update_file file
  @parameters
end
prop(k, v) click to toggle source

Allows you to add properties to MsBuild; example:

b.prop 'WarningLevel', 2 b.prop 'BuildVersion', '3.5.0'

From MSDN:

“Set or override the specified project-level properties, where name is the property name and value is the property value. Specify each property separately, or use a semicolon or comma to separate multiple properties, as the following example shows: /property:WarningLevel=2;OutputDir=binDebug”

The properties will be automatically converted to the correct syntax

# File lib/albacore/task_types/build.rb, line 92
def prop k, v
  @properties ||= Hash.new
  @parameters.delete "/property:#{make_props}" if @properties.any?
  @properties[k] = v
  @parameters.add "/property:#{make_props}"
end

Private Instance Methods

heuristic_executable() click to toggle source
# File lib/albacore/task_types/build.rb, line 200
def heuristic_executable
    return nil unless ::Rake::Win32.windows?
    require 'win32/registry'
    trace 'build tasktype finding msbuild.exe'

    msb = "msbuild_not_found"
  versions = Albacore.find_msbuild_versions
  if versions.any?
    msb = versions[versions.keys.max]
  end
    CrossPlatformCmd.which(msb) ? msb : nil
end
make_clp() click to toggle source
# File lib/albacore/task_types/build.rb, line 196
def make_clp
  @clp.join(';')
end
make_props() click to toggle source
# File lib/albacore/task_types/build.rb, line 190
def make_props
  @properties.collect { |k, v|
    "#{k}=#{v}"
  }.join(';')
end
make_target() click to toggle source
# File lib/albacore/task_types/build.rb, line 186
def make_target
  @targets.join(';')
end
set_logging(mode) click to toggle source
# File lib/albacore/task_types/build.rb, line 157
def set_logging mode
  modes = %w{quiet minimal normal detailed diagnostic}.collect{ |m| "/verbosity:#{m}" }
  @parameters.subtract modes
  @parameters.add "/verbosity:#{mode}"
end
update_array_prop(prop_name, callable_prop_val, field_sym, value) click to toggle source
# File lib/albacore/task_types/build.rb, line 163
def update_array_prop prop_name, callable_prop_val, field_sym, value
  field = :"@#{field_sym}"
  # @targets ||= []
  instance_variable_set field, [] unless instance_variable_defined? field
  # parameters.delete "/target:#{make_target}" if @targets.any?
  @parameters.delete "/#{prop_name}:#{callable_prop_val.call}" if
    instance_variable_get(field).any?
  if value.respond_to? 'each'
    value.each { |v| instance_variable_get(field) << v }
  else
    instance_variable_get(field) << value
  end
  instance_variable_get(field).uniq!
  # @parameters.add "/target:#{make_target}"
  @parameters.add "/#{prop_name}:#{callable_prop_val.call}"
end
update_file(val) click to toggle source

There can be only one

# File lib/albacore/task_types/build.rb, line 181
def update_file val
  @parameters.delete_if { |param| File.file? param }
  @parameters.add ::Albacore::Paths.normalise_slashes val
end