Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove NuGet Package from server?

Tags:

package

nuget

I have added new package to nuget(I'm not talking about adding reference of package into project). I have added new packages to server so that others can consume/use that package in their projects.

Say package name was Parser1.0.0.0.nupkg

Problem is I forgot to add one dependency. Now I want to edit or delete and add correct one again. But I don't want to change its version number.

Anyone knows how to do it?

like image 611
Balpreet Patil Avatar asked Jul 25 '12 16:07

Balpreet Patil


People also ask

How do you delete a NuGet package?

Starting in Visual Studio 2017, use the Tools > NuGet Package Manager > Package Manager Settings menu command, then select Clear All NuGet Cache(s).

Can NuGet packages be deleted?

nuget.org does not support permanent deletion of packages. Doing so would break every project depending on the availability of the package, especially with build workflows that involve package restore. nuget.org does support unlisting a package, which can be done in the package management page on the web site.

Can I delete NuGet Packages folder?

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


2 Answers

Permanently deleting packages is not supported, but you can control how they are listed. (assuming you're talking about nuget.org).

After signing in, in there is additional information on the delete package page. e.g. https://nuget.org/packages/Parser/1.0.0.0/Delete.

Quoting nuget's explanation from the delete package page :

"Why can’t I delete my package? Our policy is to only permanently delete NuGet packages that really need it, such as packages that contain passwords, malicious/harmful code, etc. This policy is very similar to the policies employed by other package managers such as Ruby Gems.

Unlisting the package will remove the package from being available in the NuGet. The package is still available for download as a dependency for three main reasons.

Other packages may depend on that package. Those packages might not necessarily be in this gallery. Ensures that folks using NuGet without committing packages (package restore) will not be broken. Helps ensure that important community owned packages are not mass deleted."

I would suggest unlisting the previous package and bumping the version to 1.0.0.1 after adding the dependency.

like image 106
Alexandre Dion Avatar answered Oct 21 '22 04:10

Alexandre Dion


Assuming you administer a private NuGetGallery server and have access to the MSSQL Server database, you can remove the package by removing the gallery's knowledge of its existence.

You should probably never use this, but in the interests of science, here's how you would disregard the good reasons not to (note that this will delete all versions of a package called 'MyNastyPackage'):

DECLARE @PackageRegistrationKey int
SELECT @PackageRegistrationKey = [Key]
 FROM PackageRegistrations
 WHERE Id = 'MyNastyPackage'

BEGIN TRANSACTION
DELETE pf
 FROM [NuGetGallery].[dbo].[PackageFrameworks] pf
 JOIN Packages p ON pf.Package_Key = p.[Key]
 WHERE PackageRegistrationKey = @PackageRegistrationKey
DELETE pa
 FROM [NuGetGallery].[dbo].[PackageAuthors] pa
 JOIN Packages p ON pa.PackageKey = p.[Key]
 WHERE PackageRegistrationKey = @PackageRegistrationKey
DELETE gs
 FROM [NuGetGallery].[dbo].[GallerySettings] gs
 JOIN [PackageStatistics] ps ON gs.DownloadStatsLastAggregatedId = ps.[Key]
 JOIN Packages p ON ps.PackageKey = p.[Key]
 WHERE PackageRegistrationKey = @PackageRegistrationKey
DELETE ps
 FROM [NuGetGallery].[dbo].[PackageStatistics] ps
 JOIN Packages p ON ps.PackageKey = p.[Key]
 WHERE PackageRegistrationKey = @PackageRegistrationKey
DELETE pd
 FROM [NuGetGallery].[dbo].[PackageDependencies] pd
 JOIN Packages p ON pd.PackageKey = p.[Key]
 WHERE PackageRegistrationKey = @PackageRegistrationKey
DELETE
 FROM [NuGetGallery].[dbo].[Packages]
 WHERE PackageRegistrationKey = @PackageRegistrationKey
DELETE por
 FROM PackageOwnerRequests por
 JOIN PackageRegistrations pr ON pr.[Key] = por.PackageRegistrationKey
 WHERE pr.[Key] = @PackageRegistrationKey
DELETE pro
 FROM PackageRegistrationOwners pro
 JOIN PackageRegistrations pr ON pr.[Key] = pro.PackageRegistrationKey
 WHERE pr.[Key] = @PackageRegistrationKey
DELETE FROM PackageRegistrations
 WHERE [Key] = @PackageRegistrationKey
COMMIT TRANSACTION
like image 38
grenade Avatar answered Oct 21 '22 05:10

grenade