NuGet 恢复无法解析主机 'www.nuget'

NuGet restore unable to resolve host 'www.nuget'

我正在尝试使用 nuget restore 命令在 CI 服务器上恢复 NuGet 包。我可以在本地 运行 它没有问题,但在服务器上我收到一些警告(错误,真的):

WARNING: The remote name could not be resolved: 'www.nuget'
WARNING: The remote name could not be resolved: 'www.nuget'
WARNING: The remote name could not be resolved: 'www.nuget'
WARNING: The remote name could not be resolved: 'www.nuget'
WARNING: The remote name could not be resolved: 'www.nuget'
WARNING: The remote name could not be resolved: 'www.nuget'
WARNING: The remote name could not be resolved: 'www.nuget'
Installing 'NSubstitute 1.8.1.0'.
Successfully installed 'NSubstitute 1.8.1.0'.
WARNING: The remote name could not be resolved: 'www.nuget'
WARNING: The remote name could not be resolved: 'www.nuget'
Unable to find version '1.7' of package 'DotSpatial.Data'.
Unable to find version '1.7' of package 'DotSpatial.Mono'.
Unable to find version '1.7' of package 'DotSpatial.Projections'.
Unable to find version '1.7' of package 'DotSpatial.Serialization'.
Unable to find version '1.7' of package 'DotSpatial.Topology'.
Unable to find version '9.1.1' of package 'JetBrains.Annotations'.
Unable to find version '1.0.0' of package 'SimpleLogger'.
Unable to find version '3.5.1' of package 'YamlDotNet'.
Unable to find version '2.0.0' of package 'NUnitTestAdapter.WithFramework'.

据我所知(类似问题链接如下),unable to resolve 是一个 DNS 问题。 The NuGet status page shows DNS as working and the fact that I can run it locally without issue seems to indicate that it is not a NuGet server issue. I am using the command-line utility downloaded directly from the NuGet website 在两个位置。我已经检查以确保没有与代理相关的环境变量干扰该过程。我在两个位置都使用 Windows 7。这可能是什么问题?

类似问题:

www.nuget 部分是问题所在——它不是正确的遥控器(至少不是完整的遥控器名称)。这很可能是您的系统配置问题以及该名称存储不正确的地方。检查 %AppData%\NuGet\ 目录中的 a configuration file 并确保它在所有地方都有正确的远程名称。

我在 %AppData%\NuGet\NuGet.config 中得到的:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="https://www.nuget.org/api/v2/" value="https://www.nuget.org/api/v2/" />
    <add key="NuGetHttp" value="http://www.nuget/api/v2/" />
  </packageSources>
  <disabledPackageSources>
    <add key="https://www.nuget.org/api/v2/" value="true" />
  </disabledPackageSources>
</configuration>

这一行尤其不正确:

<add key="NuGetHttp" value="http://www.nuget/api/v2/" />

修正上面一行中的值,你应该可以开始了。

我现在拥有的:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="https://www.nuget.org/api/v2/" value="https://www.nuget.org/api/v2/" />
    <add key="NuGetHttp" value="http://www.nuget.org/api/v2/" />
  </packageSources>
  <disabledPackageSources>
    <add key="https://www.nuget.org/api/v2/" value="true" />
  </disabledPackageSources>
</configuration>

和运行 nuget restore 有效:

Installing 'DotSpatial.Mono 1.7'.
Installing 'DotSpatial.Serialization 1.7'.
Installing 'DotSpatial.Data 1.7'.
Installing 'DotSpatial.Projections 1.7'.
Successfully installed 'DotSpatial.Mono 1.7'.
Installing 'DotSpatial.Topology 1.7'.
Successfully installed 'DotSpatial.Data 1.7'.
Installing 'JetBrains.Annotations 9.1.1'.
Successfully installed 'DotSpatial.Topology 1.7'.
Installing 'SimpleLogger 1.0.0'.
Successfully installed 'JetBrains.Annotations 9.1.1'.
Successfully installed 'SimpleLogger 1.0.0'.
Successfully installed 'DotSpatial.Serialization 1.7'.
Installing 'YamlDotNet 3.5.1'.
Installing 'NSubstitute 1.8.1.0'.
Installing 'NUnitTestAdapter.WithFramework 2.0.0'.
Successfully installed 'NUnitTestAdapter.WithFramework 2.0.0'.
Successfully installed 'YamlDotNet 3.5.1'.
Successfully installed 'NSubstitute 1.8.1.0'.
Successfully installed 'DotSpatial.Projections 1.7'.