21

while using

nuget.exe push \\share\Packages\*.nupkg -Source "https://myvsts.pkgs.visualstudio.com/_packaging/tcpcm/nuget/v3/index.json" -ApiKey VSTS

i got an

Response status code does not indicate success: 409 (Conflict).

error

is there a way to overwrite all packages that have already been uploaded?

Community
  • 1
  • 1

4 Answers4

33

is there a way to overwrite all packages that have already been uploaded?

The simple answer is No. Jonathan Myers`s answer pointed out the correct document: Understand immutability of packages.

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.

Leo Liu
  • 71,098
  • 10
  • 114
  • 135
  • ok thanks for the info, what i now did was to upload all packages to source code and then create a build definition for nuget push. it pushes all packages and the build task also allowes to skip packages that are already installed, pretty handy. –  Jul 05 '17 at 07:59
  • 2
    What would be the proper (convenient) way for developing and testing packages then? @IngoB did you figure it out? Should I really release a minor version number every time I package and test a lib? I'm just pushing to a local folder locally on my machine. – Nomnom Dec 23 '20 at 14:39
6

This is intentionally prohibited in VSTS.

Jonathan Myers
  • 789
  • 4
  • 12
4

Try adding ?replace=true at the end of the URL. Alternatively you could try AllowOverwriteExistingPackages=true.

I'm not sure if visualstudio.com already supports this, but this is how it's working in case of Octopus Deploy's NuGet server.

Dave Jarvis
  • 30,436
  • 41
  • 178
  • 315
Dávid Molnár
  • 10,673
  • 7
  • 30
  • 55
  • hey there, thanks for the info, i've already tryed both but they are not supported –  Jun 30 '17 at 10:57
  • 1
    is there a way to bulk delete all packages so i can push them again? –  Jun 30 '17 at 11:01
  • @IngoB In my experience, deleting a package v1.1 off the feed, you still cannot upload a revised v1.1. – paparush Jan 10 '19 at 13:51
  • Just to confirm, I see the same behavior on Octopus NuGet server. – ebol2000 Jan 15 '19 at 19:20
  • 1
    You can always download every package, then rename the feed, wait a few mins, create a new feed with the old name, then push all the packages except the one that you don't want - get a new set of immutable version numbers so to speak. :S – coolhandle01 Jan 19 '21 at 11:26
0

Probably not the best practice but if you need to update same version then you can always delete a package first and then push updated one with the same version.

NuGet delete command