Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uninstall NuGet package on Linux [closed]

Using .NET Core under Linux, it is possible to manage NuGet packages using several different tools: the .NET Core CLI (dotnet command) and running nuget.exe under Mono.

In the Microsoft docs it indicates that packages can be installed and uninstalled using both of those tools. It is clearly possible to install packages using either, but I have not found a way to uninstall a NuGet package using either tool.

The dotnet command provides a remove subcommand which removes the package reference from your .csproj file, but does not uninstall the package. You could also use the nuget locals subcommand with the --clear option to clear all of your installed packages, but not just a single package.

Is it possible to uninstall a single NuGet package on Linux?

like image 388
natbob1 Avatar asked Sep 05 '25 03:09

natbob1


1 Answers

The terms of "Installing" and "Uninstalling Packages" originated from the packages.config based NuGet model that downloads a local copy of the NuGet package into a folder next to the solution file. NuGet would then also modify the csproj file to add references if needed.

In the new .NET Core / "SDK-based projects" world, this is no longer the case, since you just reference a package by ID+Version and share a locally downloaded copy of the package with all other projects on your machine (technically it is global to your user account). Also, NuGet no longer needs to modify your project files to add or remove packages.

While you would want dotnet remove and similar operations to remove the reference to the package from a project, you don't necessarily want to delete the package from your global package cache since other projects may still use them. If you do remove it from the cache, a restore operation (e.g. implicitly run during dotnet build) would then re-download the package.

There is currently no built in way to remove a package reference AND delete it from the global package cache.

like image 68
Martin Ullrich Avatar answered Sep 07 '25 23:09

Martin Ullrich