Click here to Skip to main content
14,921,505 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
C#
Hi,

I have a nuget package, it is created at post build event in jenkins, I am able to create and push it to nuget.org, but, when I try to push the package with same name(id) and version number, an error is thrown, 'Package with same name and Version number already exists, cannot modify it...'

I even tried to delete the package with delete command, the nuget package is unlisted, 
when I try to push the updated package with same name and version, it throws same package exists error

Is there any way, to replace the package without any change in name and version?

If not, can I get the latest version number for my package from nuget and delete(unlist) it, so that I can push the updated package with an incremental version 
number, with this 2 step process, I shall make sure, only a version of this package is visible in the nuget package manager UI

Thanks in advance..

--Shabarinadh

What I have tried:

What I have tried:

//Create package
nuget pack MyPackage.nuspec -IncludeReferencedProjects -Prop Configuration=Release -version 1.0.0.0 -outputDirectory ./Packages -Noninteractive -Verbosity Detailed

//delete package by name[id] and version
nuget delete MyPackage.Bin 1.0.0 -Source http://nugetpackages.xx.xx.xxx.com/ -Noninteractive -Verbosity Detailed

//push package command throws error, 'package already exists.. cannot modify...'
nuget push Packages/MyPackage.Bin.1.0.0.0.nupkg -Source http://nugetpackages.xx.xx.xxx.com/ -Noninteractive -Verbosity Detailed

I am able to create and push it to nuget.org, but, when I try to push the package with same name(id) and version number, an error is thrown, 'Package with same name and Version number already exists, cannot modify it...'

I even tried to delete the package with delete command, the nuget package is unlisted, 
when I try to push the updated package with same name and version, it throws same package exists error
Posted

1 solution

Once you publish a particular version of a package to a feed, that version number is permanently reserved. You cannot upload a newer revision package with that same version number, or delete it and upload a new package at the same version.
That because many package clients, including NuGet, keep a local cache of packages on your machine. Once a client has cached a particular package@version, it will return that copy on future install/restore requests. If, on the server, you replace package@version (rev 1) with a new package@version (rev 2), the client is unable to tell the difference. This can lead to indeterminate build results from different machines.

So we could not overwrite all packages that have already been uploaded, even we could not delete them and re-uploaded. To resolve this issue, the only way is that upload the packages with a new version.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900