经过多次尝试,这就是我最终的工作。
我必须安装nuget命令行实用程序:
sudo aptitude install nuget
有关详细信息,请参阅
this
邮政。下一步是将nuget配置为使用代理:
# set proxy
$ nuget config -set http_proxy=http://proxy.com:port
$ nuget config -set https_proxy=http://proxy.com:port
# set username (in my case, the domain name was not necessary)
$ nuget config -set http_proxy.user=username
$ nuget config -set https_proxy.user=username
# set password
$ nuget config -set http_proxy.password=password
$ nuget config -set https_proxy.password=password
存储这些更改的配置文件是
~/.config/NuGet/NuGet.Config
. 在VS代码集成终端(ctrl+`)内,尝试下载软件包:
$ dotnet add package Newtonsoft.Json
您应该能够看到类似这样的输出:
Writing /tmp/tmp2RmRVL.tmp
info : Adding PackageReference for package 'Newtonsoft.Json' into project '/home/ryuzakyl/Desktop/CSharpWithVSCode/src/CSharpWithVSCode.ClassLib/CSharpWithVSCode.ClassLib.csproj'.
log : Restoring packages for /home/ryuzakyl/Desktop/CSharpWithVSCode/src/CSharpWithVSCode.ClassLib/CSharpWithVSCode.ClassLib.csproj...
info : GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json
info : OK https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json 286ms
info : Package 'Newtonsoft.Json' is compatible with all the specified frameworks in project '/home/ryuzakyl/Desktop/CSharpWithVSCode/src/CSharpWithVSCode.ClassLib/CSharpWithVSCode.ClassLib.csproj'.
info : PackageReference for package 'Newtonsoft.Json' version '12.0.1' updated in file '/home/ryuzakyl/Desktop/CSharpWithVSCode/src/CSharpWithVSCode.ClassLib/CSharpWithVSCode.ClassLib.csproj'.
希望有帮助;)