[英]How can I run NuGet commands in a PowerShell script?
我正在尝试通过PowerShell脚本运行一些NuGet命令,但是PowerShell会提示诸如以下错误:“未知的命令:'-set'”或“表达式或语句中的意外的标记'-set'”
我正在尝试运行以下NuGet命令:
$nugetExe = "C:\TestAutomation\NuGet\nuget.exe"
Invoke-Expression "$nugetExe config -set http_proxy.user= t123654"
Invoke-Expression "$nugetExe config -set http_proxy.password= njhbjhb"
PS。 :PowerShell版本为5.1,NuGet为4.6。**此代码可通过Windows CMD正常运行。
在CMD命令行上,我像这样运行它,并且它的工作原理是:
nuget.exe config -set http_proxy.user=t123645
nuget.exe config -set http_proxy.password= njhbjhb
nuget.exe没有set
参数。
我认为如果您尝试设置代理,则缺少config
参数:
nuget.exe config -set http_proxy=http://my.proxy.address:port
要使用PowerShell运行:
$nugetExe = "D:\Scrap\New folder\NuGet.exe"
$Params = @(
"config",
"-Set", "HTTP_PROXY.USER=domain\user"
"-configfile" "D:\scrap\New folder\my.config"
)
& $nugetExe $Params
我解决了 它只是关于编写它的方式。 应该是这样的:
.\nuget config -Set http_proxy.user=t514144
.\nuget config -Set http_proxy.password=njhbjhb
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.