Red Gate forums :: View topic - Publish a package to a nuget feed
Return to www.red-gate.com RSS Feed Available

Search  | Usergroups |  Profile |  Messages |  Log in  Register 
Go to product documentation

Deployment Manager PowerShell Scripts forum

Publish a package to a nuget feed

Search in Deployment Manager PowerShell Scripts forum
Post new topic   Reply to topic
Jump to:  
Author Message
PeterG



Joined: 20 Aug 2013
Posts: 4

PostPosted: Tue Aug 20, 2013 10:55 am    Post subject: Publish a package to a nuget feed Reply with quote

A script for publishing a nuget package to a feed:

Code:

# Input:
# Required
# $nugetServer = http://localhost:8080/nuget/
# $nugetPackagePath = C:\foo.nukpg
#
# Optional
# $nugetAPIKey = 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a

# For more information visit:
# http://docs.nuget.org/docs/reference/command-line-reference#Push_Command

# Requires nuget to be setup on agent



# Check if nuget is available
try {
# An error is thrown if nuget doesn't exist,
# but it's not terminating, which is not the behaviour we want
# so stop on all errors
   $temp = $ErrorActionPreference
   $ErrorActionPreference = "Stop"
   $nuget = Get-Command "nuget.exe"
   $ErrorActionPreference = $temp
} catch {
   throw "NuGet is unavailable"
}

$errors = ""
if ($null -eq $nugetServer) {
   $errors = $errors + ", nugetServer"
}
if ($null -eq $nugetPackagePath) {
   $errors = $errors + ", nugetPackagePath"
}

if (0 -ne $errors.length) {
   # Throw an error and stop deployment from continuing further
   throw ($errors.trim(", ") + " must be set to push a package")
}

nuget push -Source $nugetServer $nugetPackagePath $nugetAPIKey | Out-Default

_________________
Peter Gerrard
Intern - Deployment Manager
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic All times are GMT + 1 Hour
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group