How do I delete NuGet packages that are not referenced by any project in my solution?

前端 未结 11 1093
攒了一身酷
攒了一身酷 2021-01-30 01:53

Somehow during the upgrade to VS2012 and .NET 4.5, I\'ve managed to get NuGet confused. There are packages that appear in the package manager (and the packages folder) that I c

相关标签:
11条回答
  • 2021-01-30 02:42

    Solution 1

    Use the powershell pipeline to get packages and remove in single statement like this

    Get-Package | Uninstall-Package
    

    Solution 2

    if you want to uninstall selected packages follow these steps

    1. Use GetPackages to get the list of packages
    2. Download Nimble text software
    3. Copy the output of GetPackages in NimbleText(For each row in the list window)
    4. Set Column Seperator to ( if required
    5. Type Uninstall-Package $0 (Substitute using pattern window)
    6. Copy the results and paste them in Package Manage Console

    That be all folks.

    0 讨论(0)
  • 2021-01-30 02:43

    You can use Package Manager Console with command: Uninstall-Package PackageId to remove it, or just delete package folder from 'packages' folder under solution folder. More information about Package Manager Console you can find here: http://docs.nuget.org/docs/reference/package-manager-console-powershell-reference

    0 讨论(0)
  • 2021-01-30 02:43

    I've found a workaround for this.

    1. Enable package restore and automatic checking (Options / Package Manager / General)
    2. Delete entire contents of the packages folder (to Recycle Bin if you're nervous!)
    3. Manage Nuget Packages For Solution
    4. Click the restore button.

    NuGet will restore only the packages used in your solution. You end up with a nice, streamlined set of packages.

    0 讨论(0)
  • 2021-01-30 02:46

    One NuGet package can reference another NuGet package. So, please be very careful about inter-package dependencies. I just uninstalled a Google map package and it subsequently uninstalled underlying packages like Newtonsoft, Entity Framework, etc.

    So, manually deleting particular package from packages folder would be safer.

    0 讨论(0)
  • 2021-01-30 02:47

    From the Package Manager console window, often whatever command you used to install a package can be used to uninstall that package. Simply replace the INSTALL command with UNINSTALL.

    For example, to install PowerTCPTelnet, the command is:

    Install-Package PowerTCPTelnet -Version 4.4.9

    To uninstall same, the command is:

    Uninstall-Package PowerTCPTelnet -Version 4.4.9

    0 讨论(0)
提交回复
热议问题