NuGet Push 抛出 PackageExistsAsDeletedException

Joh*_*Koz 8 nuget azure-pipelines-release-pipeline azure-artifacts

我正在测试 VSTS 托管的 NuGet 提要,并创建了一个 NuPkg 并将其发布到该提要中,名称如下: SomeComponent.2.1.0.npkg

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

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

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
Run Code Online (Sandbox Code Playgroud)

如果我删除了这个包并清空了回收站,我之前发布过这个包的知识还有什么?

另外,为什么要关心我是否重新发布包,我不能只覆盖那里的内容吗?

Mar*_*Liu 5

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

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

假设project1正在使用SomeComponent版本为 的 nuget 包2.1.0。当您在 VSTS 提要中删除此包时,project1只会找到SomeComponent版本2.1.0不可用的 nuget 包。但是如果再次推送SomeComponent相同版本的包2.1.0(.pkg 与删除的相比具有较大的特性),则会导致 .pkg 的意外结果/错误project1

所以,简而言之,您应该为同一个nuget包推送SomeComponent删除版本不同的版本(例如2.1.1上面示例中带有版本的推送包)。

  • 谢谢@Marina Liu,我已经接受了这个答案 - 这是 VSTS Package Feed 的“设计”。但是,这在我的情况下是不可取的,因为在这种情况下我无法更改版本号。我最终删除了提要并重新创建它。建议安装一种方法来覆盖此行为,因为发布定义测试等可能会导致合法需要覆盖现有版本。 (7认同)