Sha256: 78d4ffbf6a3d5284b605af19cbab93f734ade0c9e1414f14b0f17734c667d3dc

Contents?: true

Size: 1.47 KB

Versions: 2

Compression:

Stored size: 1.47 KB

Contents

require 'albacore/albacoretask'
require 'albacore/config/nugetpackconfig'
require 'albacore/support/supportlinux'

class NuGetPack
  include Albacore::Task
  include Albacore::RunCommand
  include Configuration::NuGetPack
  include SupportsLinuxEnvironment
  
  attr_accessor  :nuspec,
                 :output,
                 :base_folder,
                 :command,
                 :symbols

  attr_hash :properties

  def initialize(command = "NuGet.exe") # users might have put the NuGet.exe in path
    super()
    update_attributes nugetpack.to_hash
    @command = command
  end

  def execute
  
    fail_with_message 'nuspec must be specified.' if @nuspec.nil?
    
    params = []
    params << "pack"
    params << "-Symbols" if @symbols
    params << "#{nuspec}"
    params << "-BasePath #{base_folder}" unless @base_folder.nil?
    params << "-OutputDirectory #{output}" unless @output.nil?
    params << build_properties unless @properties.nil? || @properties.empty?

    merged_params = params.join(' ')
    
    @logger.debug "Build NuGet pack Command Line: #{merged_params}"
    result = run_command "NuGet", merged_params
    
    failure_message = 'NuGet Failed. See Build Log For Detail'
    fail_with_message failure_message if !result
  end
  
  def build_properties
    option_text = []
    @properties.each do |key, value|
      option_text << "#{key}=\"#{value}\""
    end
    '-Properties ' + option_text.join(";")
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
albacore-1.0.0.rc.2 lib/albacore/nugetpack.rb
albacore-1.0.0.rc.1 lib/albacore/nugetpack.rb