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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 19:49:59  来源:igfitidea点击:

Where is the dotnet command executable located on Windows?

windowsvisual-studioentity-framework-core

提问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 dotnetcommand 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:

脚步:

  1. Open control panel>System and Security>System

  2. Click on Advanced system settings

  3. In advanced section, click in Environment Variables

  4. In System variables, select path and edit

  5. After semicolon, write "C:\Program Files\dotnet"

  6. Click on Ok button till end.

  1. 打开控制面板>系统和安全>系统

  2. 点击高级系统设置

  3. 在高级部分,单击环境变量

  4. 在系统变量中,选择路径并编辑

  5. 分号后写“C:\Program Files\dotnet”

  6. 单击确定按钮直到结束。

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 dotnettool 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 dotnettool 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

I have the same issue on windows 10 64bit after installing dotnet core SDK 3.1 To resolve it, I defined the environnement variables path for .netcore 3.1 and restarted my machine. enter image description here

安装 dotnet core SDK 3.1 后,我在 windows 10 64bit 上遇到了同样的问题为了解决它,我为 .netcore 3.1 定义了环境变量路径并重新启动了我的机器。 在此处输入图片说明

回答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.Toolspackage 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-MigrationUpdate-Database,等。