c# - dotnet:适用于 Windows 10 命令提示符,但不适用于 VSCode
问题描述
我开始了学习 DotNet 的旅程,并在 MS 网站上找到了一个演示应用程序,这里是:https ://docs.microsoft.com/en-us/learn/modules/create-razor-pages-aspnet-core/3 -exercise-create-new-aspnetcore-app。
尝试在 VSCode 中运行 dotnet 时出现以下错误:
The term 'dotnet' is not recognized as the name of a cmdlet
,但它可以从命令行工作。
一些信息:
- 在 Windows 10(管理员或非管理员)或 Windows PowerShell 中打开命令提示符时,
dotnet --help
会找到并响应。 - 为我自己的用户和系统帐户(只是为了确定)正确设置了 dotnet 的路径。
- 这些工具在我的用户路径中设置如下:
%USERPROFILE%\.dotnet\tools
. - 我以管理员和普通用户的身份尝试了 PowerShell 和命令提示符,以检查是否可能是用户权限提升问题导致它在 VSCode 中失败,但事实并非如此。两种用户类型都在 VSCode 之外工作。
据我所知,一切都是正确的,这里的答案对我不起作用:dotnet is not known as the name of a cmdlet
当我dotnet --version
从命令提示符或 PowerShell 执行时,我的输出是:
C:\Users\bobandalice>dotnet --info
.NET SDK (reflecting any global.json):
Version: 6.0.100
Commit: 9e8b04bbff
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.100\
Host (useful for support):
Version: 6.0.0
Commit: 4822e3c3aa
.NET SDKs installed:
6.0.100 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download
在 VSCode 中执行相同操作时,输出是这样的:
PS C:\Users\bobandalice\OneDrive\dotnetapps\RazorPagesPizza> dotnet --info
dotnet : The term 'dotnet' 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
+ dotnet --info
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (dotnet:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
有任何想法吗?
解决方案
推荐阅读
- visual-studio-2019 - 如何为多行指令添加缩进?
- sql - 在 SQL Server 执行命令中设置参数
- python - 有没有办法使用给定目录中的 numpy.genfromtxt 从 csv 读取数据?
- amazon-web-services - 如何在容器中运行 AWS SAM CLI,因为它需要运行“docker”守护程序?
- c++ - 具有两种(或更多)语言的字典并在代码运行时更改它
- tensorflow - 为什么某些隐藏单元在 GRU 自动编码器中返回零?
- time-complexity - 如何使用 dafny 证明冒泡排序的时间复杂度?
- lstm - 不记得 LSTM 的过去
- node.js - 为在 Azure 上运行的节点应用启用 gzip
- angular - 如何在延迟加载primeng表中进行客户端过滤