我正在尝试使用CLI恢复我的项目中的NuGet包。我使用的命令如下所示: NuGet.exe还原解决方案文件-ConfigFile Config文件-NoCache
解决方案文件是我的.sln文件的路径。
配置文件是我的解决方案的NuGet.Config文件夹中的.nuget文件的路径。
当我运行这个命令时,我总是“找不到软件包的版本”。任何更新的包都会发生这种情况。
在同一台机器上,我可以在Visual中打开解决方案,它可以很好地更新包。Visual被设置为使用源: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>我根据佩里的回答把它修改成这个。更新后的配置也得到了相同的结果:
<?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安全通道”消息有关,但我不知道如何解决这个问题。
发布于 2020-12-09 06:15:07
首先,您应该仔细检查nuget.config文件。
对于nuget.config文件来说,这是正确的:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
</config>
<packageSources>
<add key="public feed" value="https://api.nuget.org/v3/index.json"/>
</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 restore xxx\ConsoleApp38.sln -ConfigFile "xxx\ConsoleApp38\.nuget\nuget.config" -NoCache,它可以很好地工作。
在开头,我在<config></config>下编写任何其他节点,这些节点都会导致与您所说的相同的错误,如下所示:
错误的:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<config>
<packageSources>
<add key="public feed" value="https://api.nuget.org/v3/index.json"/>
</packageSources>
</config>
</configuration>在之后,我发现<config></config>与<packageSources></packageSources>具有相同的级别。
您应该按照这份正式文件编写nuget.config文件。
除了,如果你没有计算出你的nuget.config文件,你可以和我们分享它,让我们找到问题。此外,您还可以使用*来替换隐私信息。
更新1
也是,因为您的nuget.exe太老了,对于旧的nuget.exe可能有一些问题。您应该使用我成功测试过的最新nuget.exe v5.8.0。所以请从此链接下载。
更新2
经过进一步的调查,问题更加清楚了。
发送请求时出错。请求被中止:无法创建SSL/TLS安全通道。
您的Internet或网络协议可能有一些问题。如果您使用任何代理,请禁用它。确保你的互联网是纯净的。
此外,如果这没有帮助,请遵循以下建议:
建议
1)以管理员身份打开powershell,运行以下命令:
New-Item 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Server' -Force | Out-Null
New-ItemProperty -path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Server' -name 'Enabled' -value '0' -PropertyType 'DWord' -Force | Out-Null
New-ItemProperty -path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Server' -name 'DisabledByDefault' -value 1 -PropertyType 'DWord' -Force | Out-Null
New-Item 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Client' -Force | Out-Null
New-ItemProperty -path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Client' -name 'Enabled' -value '0' -PropertyType 'DWord' -Force | Out-Null
New-ItemProperty -path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.3\Client' -name 'DisabledByDefault' -value 1 -PropertyType 'DWord' -Force | Out-Null
Write-Host 'TLS 1.3 has been disabled.'
reg add HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319 /v SystemDefaultTlsVersions /t REG_DWORD /d 1 /f /reg:64
reg add HKLM\SOFTWARE\Microsoft\.NETFramework\v4.0.30319 /v SystemDefaultTlsVersions /t REG_DWORD /d 1 /f /reg:322)使用它打开TSL 1.2。
reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v DisabledByDefault /t REG_DWORD /d 0 /f /reg:32
reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v DisabledByDefault /t REG_DWORD /d 0 /f /reg:64
reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v Enabled /t REG_DWORD /d 1 /f /reg:32
reg add "HKLM\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client" /v Enabled /t REG_DWORD /d 1 /f /reg:643),您也可以尝试使用http://packages.nuget.org/v1/FeedService.svc/作为nuget.org源代码。
https://stackoverflow.com/questions/65207993
复制相似问题