如果存在,Nuget创建包覆盖 [英] Nuget create packages overwrite if exists

查看:134
本文介绍了如果存在,Nuget创建包覆盖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi,

I have a nuget package, it is created at post build event in jenkins, I am able to create and push it to nuget.org, but, when I try to push the package with same name(id) and version number, an error is thrown, 'Package with same name and Version number already exists, cannot modify it...'

I even tried to delete the package with delete command, the nuget package is unlisted, 
when I try to push the updated package with same name and version, it throws same package exists error

Is there any way, to replace the package without any change in name and version?

If not, can I get the latest version number for my package from nuget and delete(unlist) it, so that I can push the updated package with an incremental version 
number, with this 2 step process, I shall make sure, only a version of this package is visible in the nuget package manager UI

Thanks in advance..

--Shabarinadh

What I have tried:

What I have tried:

//Create package
nuget pack MyPackage.nuspec -IncludeReferencedProjects -Prop Configuration=Release -version 1.0.0.0 -outputDirectory ./Packages -Noninteractive -Verbosity Detailed

//delete package by name[id] and version
nuget delete MyPackage.Bin 1.0.0 -Source http://nugetpackages.xx.xx.xxx.com/ -Noninteractive -Verbosity Detailed

//push package command throws error, 'package already exists.. cannot modify...'
nuget push Packages/MyPackage.Bin.1.0.0.0.nupkg -Source http://nugetpackages.xx.xx.xxx.com/ -Noninteractive -Verbosity Detailed

I am able to create and push it to nuget.org, but, when I try to push the package with same name(id) and version number, an error is thrown, 'Package with same name and Version number already exists, cannot modify it...'

I even tried to delete the package with delete command, the nuget package is unlisted, 
when I try to push the updated package with same name and version, it throws same package exists error

推荐答案

将特定版本的软件包发布到订阅源后,将永久保留该版本号。您无法上传具有相同版本号的较新版本包,或删除它并在同一版本上传新包。

因为许多包客户端(包括NuGet)保留了本地的包缓存你的机器。一旦客户端缓存了特定的包@版本,它将在未来的安装/恢复请求中返回该副本。如果在服务器上将package @ version(rev 1)替换为新的软件包@版本(rev 2),则客户端无法区分。这可能导致来自不同机器的不确定构建结果。



因此我们无法覆盖已经上传的所有软件包,即使我们无法删除它们并重新上传。要解决此问题,唯一的方法是使用新版本上传软件包。
Once you publish a particular version of a package to a feed, that version number is permanently reserved. You cannot upload a newer revision package with that same version number, or delete it and upload a new package at the same version.
That because many package clients, including NuGet, keep a local cache of packages on your machine. Once a client has cached a particular package@version, it will return that copy on future install/restore requests. If, on the server, you replace package@version (rev 1) with a new package@version (rev 2), the client is unable to tell the difference. This can lead to indeterminate build results from different machines.

So we could not overwrite all packages that have already been uploaded, even we could not delete them and re-uploaded. To resolve this issue, the only way is that upload the packages with a new version.


这篇关于如果存在,Nuget创建包覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆