c# - Windows Server 2012:Powershell 无法识别 NuGet
问题描述
我面临的情况是 Windows Server 2012 中的 Powershell 无法识别 nuget.exe。我很确定环境变量已正确设置。但是我收到以下错误:
nuget : The term 'nuget' 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 line:1 char:1
+ nuget
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (nuget:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
即使我转到nuget.exe
存在的目录并执行,我也会收到相同的错误nuget
。
Windows CMD 正在显示nuget is not a recognized command
,但如果我nuget
在存在的目录中执行,它工作正常nuget.exe
。
我在为nuget设置环境变量时犯了错误吗?请帮忙 :)
注意:我是 dotnet 技术生态系统的新手。
解决方案
与许多 Unix 系统一样,Powershell 的路径中不包含当前目录。需要使用完整路径或显式包含当前目录。
.\nuget.exe
在 Nuget 的目录中尝试。
如文档中所述,
作为一项安全功能,PowerShell 不运行可执行(本机)命令,包括 PowerShell 脚本,除非该命令位于 Path 环境变量 $env:path 中列出的路径中,或者除非您指定脚本文件的路径。
推荐阅读
- swift - 类 --> 结构时 swiftUI+Combine 中的奇怪行为
- c++ - 关于 C++ 中 anagram 相关问题的问题
- java - Java多线程:停止以前的执行并开始新的
- javascript - 给定一组 x 和 y 坐标,在 javascript 中获取曲线方程
- visual-studio - Nuget依赖不成功
- reactjs - 无法从 react-redux 导入“UseSelector”
- python - 如何在 python 中使用 pandas 对多个 DataFrame 执行外部合并
- python - 如何从 C 模块中实例化自定义对象?
- regex - 正则表达式匹配以单词开头并以或不以数字结尾的字符串
- arrays - 在某些情况下,我必须将 `elems` 与数组一起使用才能使其工作?