【发布时间】:2021-03-20 07:26:12
【问题描述】:
我正在尝试使用 CLI 在我的项目中恢复 NuGet 包。我正在使用的命令如下所示: NuGet.exe 恢复 [解决方案文件] -ConfigFile [配置文件] -NoCache
[Solution file] 是我的 .sln 文件的路径
[Config file] 是我的解决方案的 .nuget 文件夹中 NuGet.Config 文件的路径
当我运行此命令时,我总是得到“无法找到版本
在同一台机器上,我可以在 Visual Studio 中打开解决方案,它会很好地更新包。 Visual Studio 设置为使用源:https://api.nuget.org/v3/index.json,它与报告的 CLI 使用的源相同。无法弄清楚为什么它在 VS 中有效,但在 CLI 中无效。
更新: 我原来的 nuget.config 看起来像这样:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration" value="true" />
</solution>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
</configuration>
我根据 Perry 的回答将其修改为这个。更新后的配置我得到了相同的结果:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
</config>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
<packageManagement>
<add key="format" value="0" />
<add key="disabled" value="True" />
</packageManagement>
</configuration>
将 NuGet.exe 更新到版本 5.8.0 并将详细程度设置为详细并得到以下结果:
NuGet Version: 5.8.0.6930
MSBuild auto-detection: using msbuild version '15.9.21.664' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin'. Use option -MSBuildVersion to force nuget to use a specific version of MSBuild.
MSBuild P2P timeout [ms]: 120000
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\msbuild.exe "C:\Users\buildadmin\AppData\Local\Temp\NuGetScratch\0bsxh5zl.jlh.nugetinputs.targets" /t:GenerateRestoreGraphFile /nologo /nr:false /v:q /p:NuGetRestoreTargets="C:\Users\buildadmin\AppData\Local\Temp\NuGetScratch\wc050pok.qyy.nugetrestore.targets" /p:RestoreUseCustomAfterTargets="True" /p:RestoreTaskAssemblyFile="E:\TFSBuilds\Agents\AFSDSDHandheld_Agent\_work\_tasks\NuGetInstaller_333b11bd-d341-40d9-afcf-b32d5ce6f23b\0.2.29\node_modules\nuget-task-common\NuGet\5.8.0\nuget.exe" /p:RestoreSolutionDirectory="E:\TFSBuilds\Agents\AFSDSDHandheld_Agent\_work\40\s\HANDHELD\Android\2.0\2.0.9\\" /p:RestoreConfigFile="E:\TFSBuilds\Agents\AFSDSDHandheld_Agent\_work\40\s\HANDHELD\Android\2.0\2.0.9\.nuget\NuGet.Config" /p:SolutionDir="E:\TFSBuilds\Agents\AFSDSDHandheld_Agent\_work\40\s\HANDHELD\Android\2.0\2.0.9\\" /p:SolutionName="DsdMobile"
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(725,2): warning XA0113: Google Play requires that new applications must use a TargetFrameworkVersion of v8.0 (API level 26) or above. You are currently targeting v5.0 (API level 21). [E:\TFSBuilds\Agents\AFSDSDHandheld_Agent\_work\40\s\HANDHELD\Android\2.0\2.0.9\Ross.Core.Dex\Ross.Core.Dex.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(725,2): warning XA0114: Google Play requires that application updates must use a TargetFrameworkVersion of v8.0 (API level 26) or above. You are currently targeting v5.0 (API level 21). [E:\TFSBuilds\Agents\AFSDSDHandheld_Agent\_work\40\s\HANDHELD\Android\2.0\2.0.9\Ross.Core.Dex\Ross.Core.Dex.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(725,2): warning XA0113: Google Play requires that new applications must use a TargetFrameworkVersion of v8.0 (API level 26) or above. You are currently targeting v5.0 (API level 21). [E:\TFSBuilds\Agents\AFSDSDHandheld_Agent\_work\40\s\HANDHELD\Android\2.0\2.0.9\Ross.Localization\Ross.Localization.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(725,2): warning XA0114: Google Play requires that application updates must use a TargetFrameworkVersion of v8.0 (API level 26) or above. You are currently targeting v5.0 (API level 21). [E:\TFSBuilds\Agents\AFSDSDHandheld_Agent\_work\40\s\HANDHELD\Android\2.0\2.0.9\Ross.Localization\Ross.Localization.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(725,2): warning XA0113: Google Play requires that new applications must use a TargetFrameworkVersion of v8.0 (API level 26) or above. You are currently targeting v5.0 (API level 21). [E:\TFSBuilds\Agents\AFSDSDHandheld_Agent\_work\40\s\HANDHELD\Android\2.0\2.0.9\Ross.UI\Ross.UI.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(725,2): warning XA0114: Google Play requires that application updates must use a TargetFrameworkVersion of v8.0 (API level 26) or above. You are currently targeting v5.0 (API level 21). [E:\TFSBuilds\Agents\AFSDSDHandheld_Agent\_work\40\s\HANDHELD\Android\2.0\2.0.9\Ross.UI\Ross.UI.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(725,2): warning XA0113: Google Play requires that new applications must use a TargetFrameworkVersion of v8.0 (API level 26) or above. You are currently targeting v5.0 (API level 21). [E:\TFSBuilds\Agents\AFSDSDHandheld_Agent\_work\40\s\HANDHELD\Android\2.0\2.0.9\RossServices\RossServices.csproj]
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(725,2): warning XA0114: Google Play requires that application updates must use a TargetFrameworkVersion of v8.0 (API level 26) or above. You are currently targeting v5.0 (API level 21). [E:\TFSBuilds\Agents\AFSDSDHandheld_Agent\_work\40\s\HANDHELD\Android\2.0\2.0.9\RossServices\RossServices.csproj]
Restoring NuGet package Plugin.Fingerprint.1.4.9.
Missing C:\Users\buildadmin\.nuget\packages\plugin.fingerprint\1.4.9\plugin.fingerprint.1.4.9.nupkg
WARNING: Unable to find version '1.4.9' of package 'Plugin.Fingerprint'.
C:\Users\buildadmin\.nuget\packages\: Package 'Plugin.Fingerprint.1.4.9' is not found on source 'C:\Users\buildadmin\.nuget\packages\'.
https://api.nuget.org/v3/index.json: Unable to load the service index for source https://api.nuget.org/v3/index.json.
An error occurred while sending the request.
The request was aborted: Could not create SSL/TLS secure channel.
WARNING: Unable to find version '1.4.9' of package 'Plugin.Fingerprint'.
C:\Users\buildadmin\.nuget\packages\: Package 'Plugin.Fingerprint.1.4.9' is not found on source 'C:\Users\buildadmin\.nuget\packages\'.
https://api.nuget.org/v3/index.json: Unable to load the service index for source https://api.nuget.org/v3/index.json.
An error occurred while sending the request.
The request was aborted: Could not create SSL/TLS secure channel.
NuGet Config files used:
E:\TFSBuilds\Agents\AFSDSDHandheld_Agent\_work\40\s\HANDHELD\Android\2.0\2.0.9\.nuget\NuGet.Config
Feeds used:
C:\Users\buildadmin\.nuget\packages\
https://api.nuget.org/v3/index.json
我使用的是 VS 2019,所以我不确定是否需要指定。我假设问题与“无法创建 SSL/TLS 安全通道”消息有关,但我不确定如何解决。
【问题讨论】:
-
你的
nuget.config文件是怎么写的?你能和我们分享一下吗?问题与该文件有关。 -
@Perry Qian-MSFT 更新了我的帖子以包含 nuget.config 文件的内容
-
我认为您的
nuget.exe太旧了。当我使用nuget.exev2.8.6,v 3.3.0时,就会发生错误。实际上,我用最新的v5.8.0测试了你的nuget.config,没有错误。所以我认为你的nuget.config文件没有问题。问题可能出在您的nuget.exe版本上。 -
所以我认为你应该将你的 nuget.exe 更新到最新版本。所以请从this link下载使用最新的nuget.exe
v5.8.0。 -
我也更新了答案。
标签: visual-studio nuget