我已支付通过私人 NuGet 源检索的许可 NuGet 包。当尝试从该源搜索 Visual Studio 中的任何包时,它会提示输入用户名和密码。该应用程序(Xamarin Forms)可以很好地使用这些许可包构建。
另一方面,现在 Azure DevOps 失败了,因为它无法从 nuget.org 恢复块。
经过研究,尝试了两种选择:
选项 1:使用 DevOps 中的“服务连接”通过凭据连接到此源,就像在 Visual Studio 中一样,然后使用 NuGet 还原来选择该服务连接。这会生成一个临时 nuget.config 文件,其完整内容为:<configuration/>并且该任务无法找到丢失的 NuGet。
选项 2:使用 Artifacts,并从本地计算机手动推送。我已从其位置推送了项目引用的文件,但其工件描述末尾附加了“试用版本”。构建仍然失败并出现以下错误:
##[error]The NuGet command failed with exit code(1) and error(NU1101: Unable to find package Infragistics.XF.DV. No packages exist with this id in source(s): 94785e32-5a7b-4923-93b0-abe71c3c1f4c
Run Code Online (Sandbox Code Playgroud)
我认为这两种情况都会失败,因为临时 nuget.config 文件为空。在选项2之后,配置文件被删除,所以我看不到里面到底有什么。
另请注意,使用 Visual Studio 浏览时此源非常慢。
请告知我如何将私有包引入 DevOps?
编辑答案:Nuget 恢复任务,nuget.config 路径为空,因为我预计会自动生成一个与答案内容类似的新路径。我将 Nuget.config 添加到带有 2 个提要的项目源代码中,并且它工作正常。
此外,您还可以在以下位置找到 Visual Studio 全局 Nuget.config:%AppData%\NuGet …
nuget-package nuget-package-restore xamarin.forms azure-devops