NuGet Push throws PackageExistsAsDeletedException



>我正在测试 VSTS 托管的 NuGet 源,并创建并发布了一个名为SomeComponent.2.1.0.npkg的 NuPkg

我想重新测试对发布定义所做的更改,因此我从源中删除了包,并清空了回收站。

但是现在当我尝试发布时,我收到错误:

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

如果我删除了包并清空了回收站,那么我以前发布过此包的知识是什么?

另外,为什么它应该关心我是否重新发布一个包,我不能覆盖那里的内容吗?

无法将已删除的 nuget 包再次推送到 VSTS 源中,因为你推送的版本与已删除的包相同

这是保护机制,删除的包的相同版本不应再次推送,因为它可能会导致已使用包版本的项目混淆。下面是一个示例,如果可以再次推送已删除的包,则会导致意外结果:

假设project1正在使用版本2.1.0的 nuget 包SomeComponent。在 VSTS 源中删除此包时,project1只会找到版本SomeComponent不可用的版本2.1.0的 nuget 包。但是如果可以再次推送具有相同版本2.1.0的包SomeComponent(与已删除的包相比,.pkg具有完全不同的功能(,则会对project1造成意外的结果/错误。

因此,简而言之,您应该为同一 nuget 包推送与已删除版本不同的版本(例如推送SomeComponent上面示例中版本为2.1.1的包(。

相关内容

  • 没有找到相关文章

最新更新