Skip to content

Instantly share code, notes, and snippets.

@nbarnwell
Last active August 8, 2018 14:51
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nbarnwell/8302933 to your computer and use it in GitHub Desktop.
Save nbarnwell/8302933 to your computer and use it in GitHub Desktop.
Update specific packages based on wildcard (or regex pattern) using PowerShell outside the Visual Studio Package Manager Console. Caveat: I'm not a PowerShell expert and I'm pretty sure there must be terser ways to accomplish the same, but the command-line argument requirements of nuget.exe required this to be more complex than I'd have liked. :)
gci -r -inc packages.config |
%{
([xml](get-content $_)).packages.package.id |
Add-Member -NotePropertyName 'PackageConfigFile' -NotePropertyValue $_ -PassThru
} |
?{ $_ -like 'MyCompany.*' } |
%{ nuget.exe update $_.PackageConfigFile -Id $_ -RepositoryPath (join-path (split-path (Split-Path $_.PackageConfigFile)) 'packages') }
@tpluscode
Copy link

If you have the possibility, you could try Paket instead. It comes with this any many other great features not seen in nuget.exe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment