即使我已从NuGet.config中删除了提要,Jenkins仍从nuget.org下载nuget软件包。

时间:2020-08-30 15:46:46

标签: c# .net jenkins nuget

我在内部托管nuget软件包的关系。我已经在nuget.config中添加了nexus repo url。另外,我还删除了nuget.org feed,因此它不会从Internet下载软件包。 我在同一台机器上托管了詹金斯。但是,当在jenkins中执行构建时,nuget软件包是从Internet下载的,而不是从nexus repo下载的。 jenkins是否引用任何单独的nuget.config文件?还是有任何命令删除nuget.org提要,以便我可以在jenkins中执行它!

2 个答案:

答案 0 :(得分:1)

Common NuGet configurations上NuGet的文档所述,NuGet会从多个nuget.config文件中累积设置。您没有说明如何“删除nuget.org提要”,但是我认为只有一种方法可以使它可靠和可复制。如我已经链接的文档页面和nuget.config reference page所述,在<clear />元素中允许使用一个<packageSources>元素,它告诉NuGet忽略任何累积的{{ 1}}文件。

如果您使用Visual Studio删除了nuget.org提要,那么不幸的是VS的NuGet设置过于简单,无法理解和处理多文件继承的设置。在VS中添加或删除源时,通常会编辑用户配置文件nuget.config,这意味着它会影响当前计算机和当前用户配置文件上的所有解决方案。这意味着,当您在另一台计算机上甚至在同一台计算机上使用不同的用户配置文件时,您认为已应用于解决方案的NuGet设置将不再存在。您需要使用nuget.exe,dotnet cli或仅手动编辑nuget.config xml文件。

NuGet将在其运行的任何计算机上且未在默认用户配置文件位置找到nuget.config文件的情况下,创建一个nuget.config且预先配置的nuget.config。因此,如果您的存储库未明确清除继承的源,则当nuget首次在新的用户配置文件上运行时,它将创建一个包含nuget.org的{​​{1}}。因此,如果您的解决方案没有使用nuget.config的自己的nuget.config,那么它将在您没有从用户配置文件nuget.config中删除nuget.org的任何计算机上继承nuget.org。

因此,假设所需的唯一设置是公司nuget feed,则应在回购根目录中检入nuget.org,其内容大致类似于:

<clear />

答案 1 :(得分:0)

使用<html><head><meta http-equiv=\"content-type\" content=\"text/html; charset=UTF-8\" /><meta name=\"viewport\" content=\"width=341.0px, minimum-scale=1, word-wrap=break-all, maximum-scale=1, user-scalable=no, shrink-to-fit=no\" /></head><body style=\"-webkit-text-size-adjust:none\ ">HelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHelloHello</body></html>(或—source)选项运行dotnet构建。这将允许您指定NuGet源。有关更多详细信息,请参见dotnet build docs