Skip to content
Oskar Gewalli edited this page Sep 6, 2015 · 12 revisions

Enables nuget restore throughout the solution.

nugets_restore :restore do |p|
  tc     = 'https://tc.example.com/httpAuth/app/nuget/v1/FeedService.svc/'
  source = OpenStruct.new(:name => 'tc', :uri => tc)
  p.out       = 'src/packages'       # required
  p.exe       = 'tools/NuGet.exe'    # required
  p.list_spec = '**/packages.config' # optional - is default
  p.username  = 'my user'            # optional - if using private repo
  p.password  = 'my pass'            # optional - if using private repo
  p.source    = source               # optional, w/ username n' password above
  #p.source    = 'https://example.com/NuGet.svc' # as an alternative, use string directly, will add MD5 as name
  #p.include_official = true         # optional, default false, but NuGet uses NuGet.Config, or you can...
                                     # ...set the source like above to the official nuget
  p.exclude_version                  # optional (not recommended): exclude version number in directory name where NuGet package will be restored
  p.no_cache                         # optional - disable using the machine cache.
end

As for what sources are used; by default sources are saved either in %APPDATA%/NuGet or in ~/.config/NuGet/NuGet.Config, and NuGet.exe will use them.

If you want to only use a single source, ensure that you clean our the 'global state' that NuGet sets, or use paket, which is the default for albacore init and ensure paket.dependencies only contain the locations you want to be queried.

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_restore :restore do |p|
  ...
  p.nuget_gem_exe
  ...
end

And in your gemfile add the line:

gem 'nuget'

in addition to albacore.

Clone this wiki locally