Updating all packages in a solution

Jan 3, 2011 at 4:30 PM
Hi guys,
I'm still struggling to make this work consistently for any solution with any package source. My script (installed by a nuget package in its init.ps1 file)

param($installPath, $toolsPath, $package, $project)
$global:clidePath = $toolsPath

# We should install DevStore.vsix at this point if it's not already installed.

function global:Update-Packages
$manager = $packageManagerFactory.CreatePackageManager()
foreach ($name in Get-ProjectNames)
$project = Get-Project $name
$fileSys = New-Object NuGet.PhysicalFileSystem($project.Properties.Item("FullPath").Value)
$repo = new-object NuGet.PackageReferenceRepository($fileSys, $manager.LocalRepository)
foreach ($package in $repo.GetPackages())
Update-Package $package -Project $name

On a solution where I have just installed both the package providing this script and another sample one (from a local filesystem path, although the second, "Guard" exists in the online repository too), I get the following error:

PM> update-packages
Update-Package : Unable to find package 'Clide'
At C:\Temp\ConsoleApplication1\packages\Clide.\tools\init.ps1:17 char:18
+ Update-Package <<<< $package -Project $name
+ CategoryInfo : NotSpecified: (:) [Update-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGet.VisualStudio.Cmdlets.UpdatePackageCmdlet

Which is incorrect as the package does exist! (I've just installed in that solution!).

Any ideas? (I've assembled that script from another email thread)


Daniel Cazzulino | Developer Lead | MS MVP | Clarius Consulting | +1 425.329.3471