12

I'm testing the VSTS hosted NuGet feed and have created and published a NuPkg to the feed with the name: SomeComponent.2.1.0.npkg

I wanted to re-test a change I made to the release definition, so I deleted the package from the feed, and emptied the recycle bin.

But now when I try to publish I receive the error:

Error: An unexpected error occurred while trying to push the package with VstsNuGetPush.exe. Exit code(1) and error(Error:
Microsoft.VisualStudio.Services.NuGet.WebApi.Exceptions.PackageExistsAsDeletedException: The version 2.1.0 of SomeComponent has been deleted. It cannot be restored or pushed.
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.HandleResponse(HttpResponseMessage response)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__47.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Services.WebApi.VssHttpClientBase.<SendAsync>d__29.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at VstsNuGetPush.PackageAdder.AddPackageToFeed(String feedName, BlobIdentifierWithBlocks blobId)
   at VstsNuGetPush.VstsNuGetPushOperation.AddPackageToFeed(BlobIdentifierWithBlocks blobId)
   at VstsNuGetPush.VstsNuGetPushOperation.Execute(Stream stream)
   at VstsNuGetPush.VstsNuGetPushCommand.MainCore(ILogger logger)
   at VstsNuGetPush.VstsNuGetPushCommand.Main())

Packages failed to publish

If I deleted the package and emptied the recycle bin what is still holding onto the knowledge that I've previously published this package?

Also, why should it care if I re-publish a package, can't I just overwrite what's there?

Community
  • 1
  • 1
JohnKoz
  • 908
  • 11
  • 21

1 Answers1

14

It's failed to push the deleted nuget package again into VSTS feed because you pushed the same version as the deleted package.

And it’s the protection mechanism that the same version of the deleted package should not push again, since it may cause confusion for the projects which have been used the package version. And below there is an example which causes unexpected results if the deleted package could be pushed again:

Assume project1 is using the nuget package SomeComponent with version 2.1.0. When you delete this package in VSTS feed, project1 will only find the nuget package SomeComponent with version 2.1.0 that is not available. But if the package SomeComponent with the same version 2.1.0 (the .pkg has quite different features by comparing with the deleted one) can be pushed again, it will cause unexpected result/error for project1.

So, in a few words, you should push a version different from the deleted version for the same nuget package (such as push SomeComponent package with version 2.1.1 in above example).

Alberto Solano
  • 7,972
  • 3
  • 38
  • 61
Marina Liu
  • 36,876
  • 5
  • 61
  • 74
  • 10
    Thank you @Marina Liu, I've accepted this as an answer - this is "by design" of the VSTS Package Feed. However that was undesirable in my case since I could not change the version number in this instance. I ended up deleting the feed and recreating it. Suggest installing a way to override this behavior as Release Definition testing, etc. may cause legitimate need to overwrite existing versions. – JohnKoz Jun 27 '18 at 10:38
  • Same here, deleted the entire feed and restarted because I wanted explicit control for a specific package version – Fortmann Jan 04 '22 at 18:49
  • Likewise I've upvoted this as - whilst it's not the answer I want - it is an accurate description of what Azure DevOps does with artefacts. – David Arno Apr 05 '22 at 11:35
  • So painful to delete a feed because of this... – Rossco Apr 24 '23 at 13:30
  • This is ridiculous – the developers behind DevOps server are treating us as incompetent retards. Who will push the same package name / version with different semantics after first deleting it? Give me warning in case I am so stupid but let me force-push the package nevertheless! – Palo Mraz Aug 03 '23 at 10:50