Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NuGet Push throws PackageExistsAsDeletedException

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?

like image 713
JohnKoz Avatar asked Jun 25 '18 22:06

JohnKoz


1 Answers

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).

like image 73
Marina Liu Avatar answered Sep 21 '22 23:09

Marina Liu