nuget - NuGet 推送引发 PackageExistsAsDeletedException
问题描述
我正在测试 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
如果我删除了该软件包并清空了回收站,那么我还保留着我之前发布过该软件包的知识吗?
另外,如果我重新发布一个包,它为什么要关心,我不能只覆盖那里的内容吗?
解决方案
将已删除的 nuget 包再次推送到 VSTS 提要中失败,因为您推送的版本与已删除的包相同。
并且是被删除包的同一个版本不应该再次推送的保护机制,因为这可能会导致已经使用该包版本的项目混淆。下面有一个示例,如果删除的包可以再次推送,则会导致意外结果:
假设正在使用带有 versionproject1
的 nuget 包。当您在 VSTS 提要中删除此包时,只会找到版本不可用的 nuget 包。但是如果相同版本的包(.pkg 与删除的相比有很大的不同)可以再次推送,这将导致意外的结果/错误。SomeComponent
2.1.0
project1
SomeComponent
2.1.0
SomeComponent
2.1.0
project1
因此,简而言之,您应该为同一个 nuget 包推送与已删除版本不同的版本(例如上面示例中SomeComponent
带有版本的推送包)。2.1.1
推荐阅读
- javascript - forEach 循环中的 AJAX 函数
- sql-server - 由于分区导致 SQL Server 中的查询执行缓慢
- java - 如何使用正则表达式从样式属性中删除内引号
- python - 随机森林分类器和 ROC 和 AUC 曲线误差
- elasticsearch - 在 Kibana/Elastic 搜索中的“创建转换”期间无法看到脚本化的字段值
- reactjs - webpack 文件加载器不加载背景图片 已解决
- sql - 查找按其关系的聚合属性排序的实体
- android-emulator - Google InApp Billing - 在 android 模拟器设备上测试免费试用和自动续订订阅
- reactjs - 汇总插件 postcss 不注入从 node_modules 导入的 css
- hyperlink - 在 android 中使用 LinkMovementMethod 运行一个简单的链接