Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Example rake task that downloads CI artifacts to publish nuget packages to the official feed
desc "Downloads from CI and pushes nuget packages to the official feed"
task :release, [:package] do |t, args|
require 'open-uri'
release_path = "#{buildsupport_path}/nuget_release"
clean_dir release_path
# The @teamcity_build_id is a unique identifier for the build configuration (looks like "bt234"). You can usually figure it out from your project url
artifact_url = "{@teamcity_build_id}/.lastSuccessful/"
puts "downloading artifacts from"
artifact = open(artifact_url)
unzip_file artifact.path, release_path
FileList["#{release_path}/*.nupkg"].exclude(".symbols.nupkg").each do |nupkg|
next if args[:package] && Nuget.package_name(nupkg).downcase != args[:package].downcase
sh "#{nuget} push #{nupkg}" do |ok, res|
puts "May not have published #{nupkg}" unless ok
def clean_dir(path)
mkdir_p path, :verbose => false
rm_r Dir.glob(File.join(path, "*.*")), :verbose => false
def unzip_file (file, destination)
require 'rubygems'
require 'zip/zip' { |zip_file|
zip_file.each { |f|
zip_file.extract(f, f_path) unless File.exist?(f_path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.