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?
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.
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
It is possible for private NuGet servers. Use the NuGet delete command.
nuget delete MyPackage 1.0
Update: This still doesn't address the OP's issue as it doesn't allow you to reuse the version number, because it's still being locked by the server. There is no safe way to permanently delete a specific version of a package.
If you click Delete Package in the package's sub menu (on the left), you are redirected to another page telling you this:
If you need the package permanently removed, click on the Contact Support link and we'll take care of it for you
As for me this worked totally fine, I contacted the support requesting my package to be removed because I accidently uploaded it on the productive NuGet server instead of the staging environment.
However, I would always recommend testing your package first using staging.nuget.com. You can then add the staging environment as package repository in Visual Studio for testing.
Well, in your particular case you can add a dependency by manually editing .nuspec file if you have an access to your nuget server. Open the data directory of the nuget server (where it stores its .nupkg files), find the package and either use NugetPackageExplorer tool or edit the metadata manually (.nupkg file is a zip archive, open it and edit YourPackageName.nuspec file to add a dependency).
It would look like similar to this:
<dependencies>
<dependency id="RouteMagic" version="1.1.0" />
<dependency id="RouteDebugger" version="1.0.0" />
</dependencies>