Skip to content

Instantly share code, notes, and snippets.

@rjmurillo
Last active July 31, 2020 13:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rjmurillo/b36f40943444181db2978a949710285d to your computer and use it in GitHub Desktop.
Save rjmurillo/b36f40943444181db2978a949710285d to your computer and use it in GitHub Desktop.
Useful Package Manager console commands
Get-Project –All | Add-BindingRedirect
# On large projects commands like `Update-Package -Reinstall` can take HOURS
# If the updates are broken up, then don't lock up the IDE and complete much faster (minutes vs hours)
# Reinstall all packages that match a specific targetFramework
# Useful when retargeting
gci -recurse packages.config | % { [xml]$XmlDocument = Get-Content -Path $_.FullName; $XmlDocument.packages.package | ? { $_.targetFramework -eq 'net462' } | select id | sort-object -unique | % { update-package -reinstall $_.id } }
# Reinstall all packages that have been marked with requireReinstallation
gci -recurse packages.config | % { [xml]$XmlDocument = Get-Content -Path $_.FullName; $XmlDocument.packages.package | ? { $_.requireReinstallation -eq 'true' } | select id | sort-object -unique | % { update-package -reinstall $_.id } }
# Reinstall packages for test projects only
# Uses naming convention to identify test projects
Get-Project -All | where { $_.ProjectName.EndsWith(".Tests") } | % { Update-Package -Reinstall -Project $_.ProjectName }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment