从VSTS将nuget包推送到nuget.org时,请忽略重复项 [英] Ignore duplicates when pushing nuget package to nuget.org from VSTS

查看:181
本文介绍了从VSTS将nuget包推送到nuget.org时,请忽略重复项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VSTS中建立了一个版本,该版本在存储库中的每次提交时都会触发.一切都很好,只有一个例外.

我们不会在每次提交时发布新版本的nuget软件包.因此,我们的nuget push构建步骤失败,并显示http状态代码409.

由于该错误,构建只是部分成功".我正在使用一个构建徽章,该徽章也声明相同的内容(无上下文).

如何告诉VSTS忽略409或仅替换现有软件包(位于nuget.org上)?

解决方案

您不能忽略VSTS构建中的409错误,也不能替换服务器中的现有软件包.

我建议您可以将软件包推送到发行版中,如果发行包已存在,则使发行失败.

另一种方式是,您可以在构建过程中先检查服务器中的程序包,然后再进行推送程序包(例如PowerShell,REST API),并设置推送程序包任务的条件(自定义条件).

例如:

  1. 添加变量以构建定义(例如hasPackage true)
  2. 检查程序包(PowerShell,Rest API等…)
  3. 如果该软件包已存在,请将变量设置为false()
  4. 设置推送包任务的自定义条件(例如eq(variables ['hasPackage'],'false'))

更新:

现在,NuGet推送任务支持允许跳过重复项! (只需在NuGet Push任务中选中允许跳过重复项选项即可.

I got a build in VSTS that are triggered on every commit in the repository. Everything works great with one exception.

We do not release a new version of the nuget package on every commit. So our nuget push build step fails with http status code 409. I've configured that step so that it can continue anyway.

Due to the error the build is just "partially successful". I'm using the a build badge which also states the same (without context).

How can I tell VSTS to ignore 409 or just replace the existing package (on nuget.org)?

解决方案

You can’t ignore 409 error in VSTS build and can’t replace the existing package in server.

I recommend that you can push the package in the release and fail the release if package is existing.

Another way is that, you can check the package in server before push package (e.g. PowerShell, REST API) during the build and set the condition for push package task (Custom Condition).

For example:

  1. Add a variable to build definition (e.g. hasPackage true)
  2. Check packages (PowerShell, Rest API etc…)
  3. If the package is existing, set the variable to false ("##vso[task.setvariable variable=hasPackage;]false")
  4. Set Custom condition for push package task (e.g. eq(variables['hasPackage'],'false'))

Update:

Allow duplicates to be skipped is supported in NuGet Push Task now! (Just check Allow duplicates to be skipped option in NuGet Push task.

这篇关于从VSTS将nuget包推送到nuget.org时,请忽略重复项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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