-
-
Save ChrisMcKee/daf6622bbd9eda49fc13e36e43ffc519 to your computer and use it in GitHub Desktop.
Useful Package Manager console commands
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } | |
ForEach($project in get-project -all) { ForEach($package in Get-Package -ProjectName $project.ProjectName | ?{ $_.Id -like 'System.*'}) { Uninstall-Package -ProjectName $project.ProjectName -Id $package.Id -Force;} } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment