為解決國內訪問NuGet服務器速度不穩定的問題,我們用阿里雲服務器搭建了一個NuGet鏡像,目前已上線試運行。
使用NuGet鏡像源的方法如下:
1)NuGet鏡像源地址:https://nuget.cnblogs.com/v3/index.json
2)在NuGet.Config中添加這個鏡像源:
<?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <add key="nuget.cnblogs.com" value="https://nuget.cnblogs.com/v3/index.json" protocolVersion="3" /> <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> </configuration>
注:NuGet.Config 在 Windows 中路徑是 %appdata%\NuGet\NuGet.Config ,在 Mac 與 Linux 中的路徑是 ~/.nuget/NuGet/NuGet.Config ,如果沒有 NuGet.Config 文件,可以運行 dotnet restore 命令生成。
或者在Visual Studio中的添加方法:
由於目前帶寬有限,如果出現下面的問題,說明當前帶寬跑滿了,您可以稍后再試。
The download of 'https://nuget.cnblogs.com/v3-flatcontainer/system.runtime.extensions/4.3.0/system.runtime.extensions.4.3.0.nupkg' timed out because no data was received for 60000ms.