Windows 上的 dotnet 命令可执行文件在哪里?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42588392/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Where is the dotnet command executable located on Windows?
提问by Ivan
I am exploring the new Entity Framework Core (NOT in conjunction with ASP.Net, what I am coding is just a WinForms app) and found some tutorials mentioning a dotnet
command line command needed to create "migrations". When I try it, however, it says 'dotnet' is not recognized as an internal or external command, operable program or batch file.
I have searched my hard drive for "dotnet.exe", "dotnet.bat" and "dotnet.cmd" but have found nothing. I use Visual Studio 2015 Community Edition. Where do I find this command executable? What am I to add to the %PATH%
environment variable for it to work?
我正在探索新的 Entity Framework Core(不与 ASP.Net 结合使用,我正在编码的只是一个 WinForms 应用程序)并发现一些教程提到了dotnet
创建“迁移”所需的命令行命令。然而,当我尝试它时,它说'dotnet' is not recognized as an internal or external command, operable program or batch file.
我已经在我的硬盘驱动器中搜索了“dotnet.exe”、“dotnet.bat”和“dotnet.cmd”,但什么也没找到。我使用 Visual Studio 2015 社区版。我在哪里可以找到这个命令可执行文件?我要向%PATH%
环境变量添加什么才能使其工作?
回答by Manish Jain
dotnet.exe is located in
dotnet.exe 位于
C:\Program Files\dotnet>
If you are using command prompt and getting message that 'dotnet' is not recognized as an internal or external command, operable program or batch file" then first check the above path. If you found the above path then just copy it and set it as an environment variable of your PC.
如果您正在使用命令提示符并收到“dotnet”未被识别为内部或外部命令、可运行程序或批处理文件的消息”,则首先检查上述路径。如果您找到了上述路径,则只需将其复制并设置为PC 的环境变量。
Steps:
脚步:
Open control panel>System and Security>System
Click on Advanced system settings
In advanced section, click in Environment Variables
In System variables, select path and edit
After semicolon, write "C:\Program Files\dotnet"
Click on Ok button till end.
打开控制面板>系统和安全>系统
点击高级系统设置
在高级部分,单击环境变量
在系统变量中,选择路径并编辑
分号后写“C:\Program Files\dotnet”
单击确定按钮直到结束。
now to check whether its working on not. Just open command propmpt and type
现在检查它是否在工作。只需打开命令提示符并键入
dotnet --version
This will show the dotnet version installed in your PC.
这将显示您 PC 中安装的 dotnet 版本。
回答by Ivan
I've just found the answer myself. It seems like the dotnet
tool does not get installed with Visual Studio. Installing .NET Core tools preview for Visual Studio(direct link to the .NET Core 1.0.1 tools Preview 2: DotNetCore.1.0.1-VS2015Tools.Preview2.0.3.exe) resolved the problem by adding %ProgramFiles%\dotnet\dotnet.exe
.
我刚刚自己找到了答案。该dotnet
工具似乎未随 Visual Studio 一起安装。为 Visual Studio安装.NET Core 工具预览(直接链接到 .NET Core 1.0.1 工具预览 2:DotNetCore.1.0.1-VS2015Tools.Preview2.0.3.exe)通过添加%ProgramFiles%\dotnet\dotnet.exe
.
I have faced another problem after this, however: the dotnet
tool running but saying No executable found matching command "dotnet-ef"
but this is a matter of another question. I will, however, share the solution here once I find it.
然而,在此之后我遇到了另一个问题:该dotnet
工具正在运行但说No executable found matching command "dotnet-ef"
但这是另一个问题。但是,一旦找到,我会在这里分享解决方案。
UPDATE:
更新:
As promised, here are the questionand the answerabout the thext problem I have faced (the No executable found matching command "dotnet-ef"
error).
正如所承诺的,这里是关于我遇到的问题(错误)的问题和答案No executable found matching command "dotnet-ef"
。
And here is the solutionfor the next one (the ... violates the constraint of type 'TContext'
error)
而这里是解决方案的下一个(的... violates the constraint of type 'TContext'
错误)
回答by Aniket Thakur
For me it is located at C:\Program Files\dotnet
对我来说,它位于 C:\Program Files\dotnet
You need to install .NET SDK separately. You can download and install from https://download.microsoft.com/download/1/1/5/115B762D-2B41-4AF3-9A63-92D9680B9409/dotnet-sdk-2.1.4-win-gs-x64.exe
您需要单独安装 .NET SDK。您可以从https://download.microsoft.com/download/1/1/5/115B762D-2B41-4AF3-9A63-92D9680B9409/dotnet-sdk-2.1.4-win-gs-x64.exe下载并安装
More details : https://www.microsoft.com/net/learn/get-started/windows
更多详情:https: //www.microsoft.com/net/learn/get-started/windows
Also I did not have to set up path variable. After running above installation dotnet was automatically added in path. Just open a new cmd and run -
我也不必设置路径变量。运行以上安装后,dotnet 自动添加到路径中。只需打开一个新的 cmd 并运行 -
C:\Users\anike>dotnet --version
2.1.4
回答by Jayani Sumudini
For windows the reason was that it need to run from a Command prompt outside from visual studio. execute this command in command prompt,
对于 Windows,原因是它需要从 Visual Studio 外部的命令提示符运行。在命令提示符下执行此命令,
dotnet run
网络运行
then application run in https://localhost:5001
然后应用程序在https://localhost:5001 中运行
回答by MNF
回答by Yogesh Sharma
If you are getting this error then you have to install .net core SDK and run command dotnet --info in power shell of windows server. Please make sure c:/programfiles/dotnet environment variable has been set up already if not then set up it also. for more help please visit https://www.yogeshdotnet.com
如果出现此错误,则必须安装 .net core SDK 并在 Windows Server 的 power shell 中运行命令 dotnet --info。请确保已经设置了 c:/programfiles/dotnet 环境变量,如果没有,则也设置它。如需更多帮助,请访问https://www.yogeshdotnet.com
回答by bricelam
If you're using .NET Framework 4.x and WinForms, you probably don't want to use the .NET Core tools (i.e. dotnet ef
). Instead, install the Microsoft.EntityFrameworkCore.Tools
package and use the NuGet Package Manager Console(or PMC) PowerShell cmdlets: Add-Migration
, Update-Database
, etc.
如果您使用 .NET Framework 4.x 和 WinForms,您可能不想使用 .NET Core 工具(即dotnet ef
)。相反,安装Microsoft.EntityFrameworkCore.Tools
包,并使用的NuGet包管理器控制台(或PMC)PowerShell命令:Add-Migration
,Update-Database
,等。