Class: Albacore::NugetsPack::Config

Inherits:
Object
  • Object
show all
Extended by:
ConfigDSL
Includes:
CmdConfig
Defined in:
lib/albacore/task_types/nugets_pack.rb

Overview

This tasktype allows you to quickly package project files to nuget packages.

Point files to the project files, that should be in MsBuild XML.

Examples

nugets_pack :pack => ['build/pkg', :versioning] do |p|
  p.files   = FileList['src/**/*.csproj']
  p.out     = 'build/pkg'
  p.exe     = 'buildsupport/NuGet.exe'
  p. do |m|
    m.version = ENV['NUGET_VERSION']
  end
  p.gen_symbols
  p.no_project_dependencies
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ConfigDSL

attr_path, attr_path_accessor

Methods included from CmdConfig

#add_parameter, #parameters

Methods included from Logging

#debug, #err, #error, #fatal, #info, #puts, #trace, #warn

Constructor Details

#initializeConfig

Returns a new instance of Config.



146
147
148
149
150
151
152
153
154
155
156
# File 'lib/albacore/task_types/nugets_pack.rb', line 146

def initialize
  @package = Albacore::NugetModel::Package.new
  @target  = ''
  @symbols = false
  @project_dependencies = true
  @nuget_dependencies = true
  @package_analysis = true
  @leave_nuspec = false
  @mono_opt_out = false
  fill_required
end

Instance Attribute Details

#configuration=(value) ⇒ Object (writeonly)

sets the MsBuild configuration that is used to produce the output into <OutputPath>…</OutputPath>



144
145
146
# File 'lib/albacore/task_types/nugets_pack.rb', line 144

def configuration=(value)
  @configuration = value
end

#files=(value) ⇒ Object (writeonly)

sets the files to search



136
137
138
# File 'lib/albacore/task_types/nugets_pack.rb', line 136

def files=(value)
  @files = value
end

#nuspec=(value) ⇒ Object (writeonly)

sets the nuspec file



139
140
141
# File 'lib/albacore/task_types/nugets_pack.rb', line 139

def nuspec=(value)
  @nuspec = value
end

#target=(value) ⇒ Object (writeonly)

the .net target (e.g. net40, mono20, mono3, etc)



133
134
135
# File 'lib/albacore/task_types/nugets_pack.rb', line 133

def target=(value)
  @target = value
end

Instance Method Details

#gen_symbolsObject

generate symbols for the nugets: just call this method to enable generation



173
174
175
# File 'lib/albacore/task_types/nugets_pack.rb', line 173

def gen_symbols
  @symbols = true
end

#leave_nuspecObject

leave the nuspec behind, don’t delete it after generating it



179
180
181
# File 'lib/albacore/task_types/nugets_pack.rb', line 179

def leave_nuspec
  @leave_nuspec = true
end

#mono_opt_outObject



158
159
160
# File 'lib/albacore/task_types/nugets_pack.rb', line 158

def mono_opt_out
  @mono_opt_out = true
end

#no_nuget_dependenciesObject

call this if you want to cancel inclusion of package dependencies when creating the nuspec file



191
192
193
# File 'lib/albacore/task_types/nugets_pack.rb', line 191

def no_nuget_dependencies
  @nuget_dependencies = false
end

#no_package_analysisObject

call this if you want to disable NuGet’s package analysis when creating the nupkg file



197
198
199
# File 'lib/albacore/task_types/nugets_pack.rb', line 197

def no_package_analysis
  @package_analysis = false
end

#no_project_dependenciesObject

call this if you want to cancel ‘smart’ scanning of the *proj file for its dependencies



185
186
187
# File 'lib/albacore/task_types/nugets_pack.rb', line 185

def no_project_dependencies
  @project_dependencies = false
end

#nuget_gem_exeObject



201
202
203
# File 'lib/albacore/task_types/nugets_pack.rb', line 201

def nuget_gem_exe
  @exe = Albacore::Nugets::find_nuget_gem_exe
end

#optsObject

gets the options specified for the task, used from the task



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
# File 'lib/albacore/task_types/nugets_pack.rb', line 206

def opts
  files = @files.respond_to?(:each) ? @files : [@files]

  unless @nuspec
    [:authors, :description, :version].each do |required|
      warn "metadata##{required} is missing from nugets_pack [nugets pack: config]" if @package..send(required) == 'MISSING'
    end
  end

  Map.new({
    :out           => @out,
    :nuspec        => @nuspec,
    :exe           => @exe,
    :symbols       => @symbols,
    :package       => @package,
    :target        => @target,
    :files         => files,
    :configuration => @configuration,
    :project_dependencies => @project_dependencies,
    :nuget_dependencies => @nuget_dependencies,
    :package_analysis => @package_analysis,
    :mono_opt_out     => @mono_opt_out,
    :original_path => FileUtils.pwd,
    :leave_nuspec  => @leave_nuspec
  })
end

#with_metadata {|@package.metadata| ... } ⇒ Object

Yields:

  • (@package.metadata)


162
163
164
# File 'lib/albacore/task_types/nugets_pack.rb', line 162

def  &block
  yield @package.
end

#with_package {|@package| ... } ⇒ Object

configure the package with a block

Yields:

  • (@package)


167
168
169
# File 'lib/albacore/task_types/nugets_pack.rb', line 167

def with_package &block
  yield @package
end