Skip to content
Henrik Feldt edited this page May 23, 2017 · 15 revisions

This task type will automatically construct nuget packages for each of the projects you've given it as an Enumerable (the assignment to #files).

It will use the metadata that's already available in the xxproj-file to construct the nuget metadata, instead of forcing you to populate a nuspec file manually.

You can override the metadata by setting values inside #with_metadata.

The project's <Name /> element will map to the id and title nuspec attributes, unless an Id element has been given, in which case it will map to the id nuspec attribute, and <Title /> to the title nuspec attribute.

nugets_pack :create_nugets do |p|
  p.configuration = 'Release'
  p.files   = FileList['src/**/*.{csproj,fsproj,nuspec}'].
    exclude(/Tests/)
  # This line will bypass creating a nuspec file and configure the task with a precompiled nuspec file
  p.nuspec   = 'nuget/app.nuspec'
  p.out     = 'build/pkg'
  p.exe     = 'buildsupport/NuGet.exe'
  # This line will leave the nuspec so you can inspect and verify it, take it out if you don't want the nuspec file to
  # stay around.
  p.leave_nuspec
  p.with_metadata do |m|
    m.description = 'A cool nuget'
    m.authors = 'Henrik'
    m.version = ENV['NUGET_VERSION']
    m.add_dependency "NugetId", "[1.0.0)"
  end
  p.with_package do |p|
    p.add_file 'file/relative/to/proj', 'lib/net40'
  end
  # p.mono_opt_out # you are calling your own wrapper
end

The available metadata properties are in the nuspec specification. Translate the camel case property to snake case. You can also browse the albacore code to a list.

nugets_pack Config##no_project_dependencies

Cancel following of references between projects that cause nugets_pack to find and add as nuget dependencies, linked projects.

building a nuget symbol package

nugets_pack :create_nugets do |p|
  ...
  p.gen_symbols
  ...
end

if you have nuget gem installed

Instead of having nuget in your source you can depend on the nuget gem So in the above example you can replace "p.exe" with "p.nuget_gem_exe":

nugets_pack :create_nugets do |p|
  ...
  p.nuget_gem_exe
  ...
end

And in your gemfile add the line:

gem 'nuget'

in addition to albacore.

Clone this wiki locally