通过构建服务器还原 Nuget "unable to find version"
Nuget Restore via build server "unable to find version"
我有一个 VS 解决方案,作为 TeamCity 构建的一部分,我们从私有 NuGet 源 (myget) 和 public 源 (nuget.org) 恢复包。大多数包恢复正常,但它挂在下面的 WebApi 和 Mono.Security 上。这一切都在 Visual Studio.
本地工作
[restore] NuGet command: C:\TeamCity\buildAgent\plugins\nuget-agent\bin\JetBrains.TeamCity.NuGetRunner.exe C:\TeamCity\buildAgent\tools\NuGet.CommandLine.DEFAULT.nupkg\tools\NuGet.exe restore C:\TeamCity\buildAgent\work3bd084b49f7d88\DataFinch.Web.sln -Source https://www.myget.org/F/datafinch/auth/<hidden>/api/v2 -Source https://api.nuget.org/v3/index.json
[11:41:35][restore] Starting: C:\TeamCity\buildAgent\temp\agentTmp\custom_script473789219385667038.cmd
[11:41:35][restore] in directory: C:\TeamCity\buildAgent\work3bd084b49f7d88
[11:41:35][restore] JetBrains TeamCity NuGet Runner 8.0.37059.9
[11:41:35][restore] Registered additional extensions from paths: C:\TeamCity\buildAgent\plugins\nuget-agent\bin\plugins-2.8
[11:41:35][restore] Starting NuGet.exe 2.8.50926.602 from C:\TeamCity\buildAgent\tools\NuGet.CommandLine.DEFAULT.nupkg\tools\NuGet.exe
[11:41:43][restore] Unable to find version '5.2.3' of package 'Microsoft.AspNet.WebApi.Client'.
[11:41:43][restore] Unable to find version '5.2.3' of package 'Microsoft.AspNet.WebApi.Core'.
[11:41:43][restore] Unable to find version '3.2.3.0' of package 'Mono.Security'.
[11:41:43][restore] Unable to find version '6.0.4' of package 'Newtonsoft.Json'.
[11:41:43][restore] Process exited with code 1
Teamcity 配置:
根据 nuget 文档尝试使用 https://www.nuget.org/api/v2
而不是 https://api.nuget.org/v3/index.json
:https://docs.nuget.org/consume/Command-Line-Reference.
构建失败的原因是 nuget.exe 的旧版本。我终于通过下载最新版本并将此可执行文件放在 Program Files x86 文件夹中解决了这个问题。然后我创建了一个新的系统变量来指向这个可执行文件。之后,我在我的 TFS 构建定义中添加了一个 NuGetInstaller 包,让我可以使用这个新的 NuGet.exe 配置 TFS。
This link helped me to let TFS use this new NuGet version
我试过 3.3 并遇到了这个错误:
Restoring NuGet package Microsoft.AspNet.WebPages.3.2.3.
WARNING: Unable to find version '3.5.0.2' of package 'Antlr'.
我下载了最新的 NuGet 4.3.0.4406 并将自定义路径设置为 NuGet,但同样失败。
令人惊讶的是,当我切换到 3.5 时它起作用了。
如果您真的卡住了,运行 命令行提示符中的命令将会起作用:
C:\Program Files (x86)\NuGet\nuget.exe restore -NonInteractive E:\agentXYZPool\_work\s\xyz.sln
我 运行 解决了这个问题,我们的一个构建奴隶利用 TFS 和 Visual Studio。
我修复它的方法是,我打开了未在 Visual Studio 中编译的解决方案,右键单击 SLN 并选择 "Enable Restore NuGet Packages"
这将提示您必须接受的对话框。完成后,您可能就可以开始了。再次右击 SLN 运行 "Restore NuGet Packages",如果操作成功,你就成功了。
在设置从属环境时,您可能可以通过编程方式调整一些设置,但这是解决此类问题的一种直接方法。
根据THIS current document as of this writing from MS, the proper url is: https://api.nuget.org/v3/index.json
所以我着手解决这个问题,因为我认为它与 URL 无关。我做了 2 件事,不确定是哪一个解决了问题,但我会 post 两件事都在这里,以防它对某人有帮助。
在 TFS2018 和我安装 Nuget 的构建步骤中,我指定了版本 4.9.3(我选择 4.9.3 的原因是因为我在构建过程中通过查看 VS 的详细日志注意到它使用的是这个版本)并选择始终下载最新版本。
我做的第二件事是从我的项目中删除了一个 Nuget.Config 文件,该文件是我正在测试的东西遗留下来的。然后我重新提交了对 TFS
的更改
完成上述两个步骤后,其余构建开始工作。
使用旧版本的 Visual Studio 的 Nuget
- Visual Studio 有
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\Nuget.exe
。詹金斯用它来 nuget restore
- 更新了程序文件中的 Nuget,
C:\Program Files (x86)\NuGet> ./nuget.exe update -self
- 向 Jenkins 指出新的 Nuget 路径和用煤气做饭
SET PATH=%PATH%;C:\Program Files (x86)\NuGet
nuget restore SolutionName.sln
我有一个 VS 解决方案,作为 TeamCity 构建的一部分,我们从私有 NuGet 源 (myget) 和 public 源 (nuget.org) 恢复包。大多数包恢复正常,但它挂在下面的 WebApi 和 Mono.Security 上。这一切都在 Visual Studio.
本地工作[restore] NuGet command: C:\TeamCity\buildAgent\plugins\nuget-agent\bin\JetBrains.TeamCity.NuGetRunner.exe C:\TeamCity\buildAgent\tools\NuGet.CommandLine.DEFAULT.nupkg\tools\NuGet.exe restore C:\TeamCity\buildAgent\work3bd084b49f7d88\DataFinch.Web.sln -Source https://www.myget.org/F/datafinch/auth/<hidden>/api/v2 -Source https://api.nuget.org/v3/index.json
[11:41:35][restore] Starting: C:\TeamCity\buildAgent\temp\agentTmp\custom_script473789219385667038.cmd
[11:41:35][restore] in directory: C:\TeamCity\buildAgent\work3bd084b49f7d88
[11:41:35][restore] JetBrains TeamCity NuGet Runner 8.0.37059.9
[11:41:35][restore] Registered additional extensions from paths: C:\TeamCity\buildAgent\plugins\nuget-agent\bin\plugins-2.8
[11:41:35][restore] Starting NuGet.exe 2.8.50926.602 from C:\TeamCity\buildAgent\tools\NuGet.CommandLine.DEFAULT.nupkg\tools\NuGet.exe
[11:41:43][restore] Unable to find version '5.2.3' of package 'Microsoft.AspNet.WebApi.Client'.
[11:41:43][restore] Unable to find version '5.2.3' of package 'Microsoft.AspNet.WebApi.Core'.
[11:41:43][restore] Unable to find version '3.2.3.0' of package 'Mono.Security'.
[11:41:43][restore] Unable to find version '6.0.4' of package 'Newtonsoft.Json'.
[11:41:43][restore] Process exited with code 1
Teamcity 配置:
根据 nuget 文档尝试使用 https://www.nuget.org/api/v2
而不是 https://api.nuget.org/v3/index.json
:https://docs.nuget.org/consume/Command-Line-Reference.
构建失败的原因是 nuget.exe 的旧版本。我终于通过下载最新版本并将此可执行文件放在 Program Files x86 文件夹中解决了这个问题。然后我创建了一个新的系统变量来指向这个可执行文件。之后,我在我的 TFS 构建定义中添加了一个 NuGetInstaller 包,让我可以使用这个新的 NuGet.exe 配置 TFS。 This link helped me to let TFS use this new NuGet version
我试过 3.3 并遇到了这个错误:
Restoring NuGet package Microsoft.AspNet.WebPages.3.2.3. WARNING: Unable to find version '3.5.0.2' of package 'Antlr'.
我下载了最新的 NuGet 4.3.0.4406 并将自定义路径设置为 NuGet,但同样失败。
令人惊讶的是,当我切换到 3.5 时它起作用了。
如果您真的卡住了,运行 命令行提示符中的命令将会起作用:
C:\Program Files (x86)\NuGet\nuget.exe restore -NonInteractive E:\agentXYZPool\_work\s\xyz.sln
我 运行 解决了这个问题,我们的一个构建奴隶利用 TFS 和 Visual Studio。
我修复它的方法是,我打开了未在 Visual Studio 中编译的解决方案,右键单击 SLN 并选择 "Enable Restore NuGet Packages"
这将提示您必须接受的对话框。完成后,您可能就可以开始了。再次右击 SLN 运行 "Restore NuGet Packages",如果操作成功,你就成功了。
在设置从属环境时,您可能可以通过编程方式调整一些设置,但这是解决此类问题的一种直接方法。
根据THIS current document as of this writing from MS, the proper url is: https://api.nuget.org/v3/index.json
所以我着手解决这个问题,因为我认为它与 URL 无关。我做了 2 件事,不确定是哪一个解决了问题,但我会 post 两件事都在这里,以防它对某人有帮助。
在 TFS2018 和我安装 Nuget 的构建步骤中,我指定了版本 4.9.3(我选择 4.9.3 的原因是因为我在构建过程中通过查看 VS 的详细日志注意到它使用的是这个版本)并选择始终下载最新版本。
我做的第二件事是从我的项目中删除了一个 Nuget.Config 文件,该文件是我正在测试的东西遗留下来的。然后我重新提交了对 TFS
的更改
完成上述两个步骤后,其余构建开始工作。
使用旧版本的 Visual Studio 的 Nuget
- Visual Studio 有
C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\Nuget.exe
。詹金斯用它来nuget restore
- 更新了程序文件中的 Nuget,
C:\Program Files (x86)\NuGet> ./nuget.exe update -self
- 向 Jenkins 指出新的 Nuget 路径和用煤气做饭
SET PATH=%PATH%;C:\Program Files (x86)\NuGet nuget restore SolutionName.sln