为什么dotnet script安装后不能在 PowerShell 中运行?安装后我关闭并重新打开了所有 PowerShell 实例。
PowerShell 在我运行时抛出此错误dotnet script init:
找不到与命令“dotnet-script”匹配的可执行文件
编辑:
dotnet script确实运行cmd.exe- 和文件
dotnet夹.dotnet\tools存在于PATH
为什么dotnet script安装后不能在 PowerShell 中运行?安装后我关闭并重新打开了所有 PowerShell 实例。
PowerShell 在我运行时抛出此错误dotnet script init:
找不到与命令“dotnet-script”匹配的可执行文件
编辑:
dotnet script确实运行cmd.exedotnet夹.dotnet\tools存在于PATH虽然我确信您自己的解决方案有所帮助,但值得深入挖掘:
和文件夹存在于 PATH
dotnet中.dotnet\tools
要产生你的症状,前者必须是真的,但不能是后者:
正是它dotnet.exe发出了错误消息(暗示它dotnet.exe本身确实在PATH 中)。
该错误消息表明script找不到名为的工具,这意味着dotnet-script.exe在 PATH 中找不到名为的可执行文件,因为这是dotnet您调用时在后台构建的可执行文件名称dotnet script。
With a properly set up PATH (and, of course, dotnet-script installed), dotnet-script.exe should be found via the $HOME\.dotnet\tools directory in the PATH.
$HOME\.dotnet\tools is an entry stored as part of the user-specific PATH additions in the registry, and your PowerShell session seemingly hadn't picked up that entry yet - which can happen for the reasons mentioned in your answer.
很可能包含的文件夹dotnet不在您的 PATH 环境变量中。将其添加到该变量。
另请注意,如果您同时安装 x86 和 x64 版本,dotnet 将安装在两个位置,并且仅当两者都在 PATH 中时才会选择一个。这会在更新时导致非常奇怪的结果!