Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget Clean Package Remove/Install

I'd like to remove an entire nuget package, and cleanly install it in my project again.

Sadly, for some reason it skips removing files that have been "modified", and then skips putting them in the project on reinstall, because they already exist.

Is there any flag i can set to unconditionally remove every single trace of a nuget package, alternatively overwrite all existing files?

Thanks.

like image 780
Andreas Eriksson Avatar asked Jun 21 '11 06:06

Andreas Eriksson


People also ask

How do I uninstall and reinstall NuGet package manager?

Switch to the Browse tab, search for the package name, select it, then select Install). For all packages, delete the package folder, then run nuget install . For a single package, delete the package folder and use nuget install <id> to reinstall the same one.

Can I delete C :\ Users NuGet packages?

Yes, the . nuget folder is used as a cache for packages downloaded to speed up project restore and compilation. It can safely be removed.

How do I uninstall NuGet package manager?

To uninstall a NuGet package, follow these steps: Load a project in Solution Explorer, select Project > Manage NuGet Packages, and then select the Installed tab. Select the package to uninstall in the left pane (use the Search box to find it, if necessary), and then select Uninstall from the right pane.

How do I stop a NuGet package from restoring?

Go to Tools -> Options -> NuGet Package Manager -> General -> Package Restore. The first option disables restore itself, while the 2nd option disables on build restore.


1 Answers

Unfortunately at the moment, NuGet does not do what you want. During the uninstall process, NuGet will only delete content files if they have not been modified. And as you've noticed, the update process will not update files that were modified either.

The Uninstall-Package command does have a -Force option, but that is to "force" uninstall even if there are other packages that depend on this one.

We can certainly file this as an issue and perhaps incorporate it into a future version.

Another option would be to create a PowerShell script that will enumerate a package's contents, then allow you to delete all the content files. I'll see if there is a simple way to do this.

BTW: Perhaps you can figure out a better way to extend the existing content file other than modifying it directly. Especially since you're losing your changes when the package is updated.

like image 81
Kiliman Avatar answered Sep 23 '22 06:09

Kiliman