Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

PowerShell Nuget Feed Issue

$
0
0

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 = 'http://nuget.testsite.net/nuget/packages'

 

# Updade the nuget exe first, if required.

.\nuget\Nuget.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){

 

\.nuget\NuGet.exe install $packagesConfig.FullName -o Source\Packages $source 

 

}

 

 

Write-Host "Press any key to continue..."

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

 

 

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles