【发布时间】:2019-03-16 07:28:15
【问题描述】:
我正在尝试通过 PowerShell 脚本运行一些 NuGet 命令,但 PowerShell 提示错误,例如:“Unknown command:'-set'”或“Unexpected token '-set' in expression or statement”
我正在尝试运行以下 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
【问题讨论】:
-
但是即使我输入第三个命令它也不起作用。我将从那里删除它,所以它更清楚。
-
如果您有有效的批处理代码,请将其发布在您的问题中。
-
对不起,我没有通过批处理文件运行它,但我在那里添加了我如何直接通过 CMD 运行它
-
我得到 "Unknown command: '-set'" running
nuget.exe -set http_proxy.user= t123654withcmd.exeand NuGet 4.7.1.5393 (latest stable) 和 NuGet 4.6.2.5055。 -
多么奇怪,对我来说它通过 cmd 运行。我现在运行它以确保一切正常,我的 Nuget.config 已更新。你是从 nuget.exe 目录运行的吗?
标签: powershell nuget