Class: NuGetPack

Inherits:
Object
  • Object
show all
Includes:
Albacore::RunCommand, Albacore::Task, Configuration::NuGetPack, SupportsLinuxEnvironment
Defined in:
lib/albacore/nugetpack.rb

Instance Attribute Summary collapse

Attributes included from SupportsLinuxEnvironment

#is_linux

Attributes included from Albacore::RunCommand

#working_directory

Attributes included from Logging

#current_log_device, #logger

Instance Method Summary collapse

Methods included from SupportsLinuxEnvironment

#format_path, #format_reference, #to_OS_format

Methods included from Configuration::NuGetPack

#nugetpack, nugetpackconfig

Methods included from Albacore::Configuration

included

Methods included from Albacore::RunCommand

#get_command, #run_command

Methods included from AttrMethods

#attr_array, #attr_hash

Methods included from Albacore::Task

clean_dirname, create_rake_task, include_config, included

Methods included from UpdateAttributes

#<<, #update_attributes

Methods included from YAMLConfig

#configure, #load_config_by_task_name

Methods included from Logging

#create_logger, #log_device=, #log_level, #log_level=

Methods included from Failure

#fail_with_message

Constructor Details

#initialize(command = "NuGet.exe") ⇒ NuGetPack

users might have put the NuGet.exe in path



19
20
21
22
23
# File 'lib/albacore/nugetpack.rb', line 19

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

Instance Attribute Details

#base_folderObject

Returns the value of attribute base_folder.



11
12
13
# File 'lib/albacore/nugetpack.rb', line 11

def base_folder
  @base_folder
end

#commandObject

Returns the value of attribute command.



11
12
13
# File 'lib/albacore/nugetpack.rb', line 11

def command
  @command
end

#nuspecObject

Returns the value of attribute nuspec.



11
12
13
# File 'lib/albacore/nugetpack.rb', line 11

def nuspec
  @nuspec
end

#outputObject

Returns the value of attribute output.



11
12
13
# File 'lib/albacore/nugetpack.rb', line 11

def output
  @output
end

#symbolsObject

Returns the value of attribute symbols.



11
12
13
# File 'lib/albacore/nugetpack.rb', line 11

def symbols
  @symbols
end

Instance Method Details

#build_propertiesObject



46
47
48
49
50
51
52
# File 'lib/albacore/nugetpack.rb', line 46

def build_properties
  option_text = []
  @properties.each do |key, value|
    option_text << "#{key}=\"#{value}\""
  end
  '-Properties ' + option_text.join(";")
end

#executeObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/albacore/nugetpack.rb', line 25

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