PowerShell Nuget Feed Issue

by Jan 17, 2015

We are having an issue with the Team City build pulling the Nuget packages from the cache reather than getting the latest from the Nuget Feed.  To resolve the issue we want to make a powershell script that will update the Nuget.exe to the latest version if needed, delete the packages folder, and then pull down the latest packages from the Nuget Feed based on the packages.config file.  I have not worked with powershell before, so I am not sure if I am on the right track.  Any guidance is greatly appreciated! 


Here is the code that I have:

$webClient = New-Object System.Net.WebClient

$source = 'nuget.testsite.net/…/packages'


# Updade the nuget exe first, if required.

.nugetNuget.exe update -self


# Delete packages folder

if (Test-Path packages){

        Write-Host "Delete packages folder."

        Remove-Item packages -recurse



# Update packages using NuGet

$packagesConfigFiles = Get-ChildItem $path -Recurse | Where-Object {$_.Name -eq "packages.config"}


foreach($packagesConfig in $packagesConfigFiles){


.nugetNuGet.exe install $packagesConfig.FullName -o SourcePackages $source 





Write-Host "Press any key to continue…"

$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp") > $null