powershell不能调用nuget.exe命令
我有一个powershell脚本,可以检查nuget.exe是否存在,并且运行'nuget help',
# Check if NuGet.exe is available.
if (-not (Get-Command "NuGet.exe" -ErrorAction SilentlyContinue))
{
Write-Host "ERROR: NuGet.exe is not available. Install NuGet.exe and add to PATH or copy NuGet.exe into C:\Windows."
exit
}
Write-Host "Confirmed NuGet.exe is in the path."
# run nuget command
$result = Invoke-Executable NuGet.exe "help"
Write-Host "result = $result"
如果我运行脚本,我在运行nuget.exe命令时会出现错误,即使找到了nuget.exe:
Confirmed NuGet.exe is in the path.
Invoke-Executable : The term 'Invoke-Executable' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At D:\repos\xdcr-nuget\packaging and publishing\auto.ps1:9 char:11
+ $result = Invoke-Executable NuGet.exe "help"
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Invoke-Executable:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
result =
在我的外面 :脚本,仅从powershell命令行我可以运行nuget命令,例如nuget help
完全可以。但是,如果没有此错误,PowerShell脚本无法运行任何Nuget命令,我在设置PowerShell脚本的方式上做错了什么?
I have a powershell script which checks if nuget.exe exists, and runs 'nuget help'
# Check if NuGet.exe is available.
if (-not (Get-Command "NuGet.exe" -ErrorAction SilentlyContinue))
{
Write-Host "ERROR: NuGet.exe is not available. Install NuGet.exe and add to PATH or copy NuGet.exe into C:\Windows."
exit
}
Write-Host "Confirmed NuGet.exe is in the path."
# run nuget command
$result = Invoke-Executable NuGet.exe "help"
Write-Host "result = $result"
if I run the script, I get an error when running the nuget.exe command, even though it says nuget.exe was found:
Confirmed NuGet.exe is in the path.
Invoke-Executable : The term 'Invoke-Executable' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At D:\repos\xdcr-nuget\packaging and publishing\auto.ps1:9 char:11
+ $result = Invoke-Executable NuGet.exe "help"
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Invoke-Executable:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
result =
outside of my script, just from the powershell command line I can run nuget commands such as nuget help
perfectly fine. but the powershell script is unable to run any nuget command without this error, am i doing something wrong with how I setup my powershell script?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论