I am trying to run some NuGet commands through a PowerShell script, but PowerShell prompts errors like: "Unknown command:'-set'" or "Unexpected token '-set' in expression or statement"
I'm trying to run the following NuGet commands:
$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. : The PowerShell version is 5.1 and NuGet is 4.6.**This code works fine through Windows CMD.
On the CMD command line I run it like this, and it works:
nuget.exe config -set http_proxy.user=t123645
nuget.exe config -set http_proxy.password= njhbjhb
nuget.exe doesn't have a set
parameter.
I think you are missing the config
parameter if you are trying to set the proxy:
nuget.exe config -set http_proxy=http://my.proxy.address:port
To run with 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
I solved it. It is just about the way of writing it. It should be like this:
.\nuget config -Set http_proxy.user=t514144
.\nuget config -Set http_proxy.password=njhbjhb
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.