Where is the dotnet command executable located on Windows?

僤鯓⒐⒋嵵緔 提交于 2019-12-20 18:31:46

问题


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?


回答1:


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.

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.

UPDATE:

As promised, here are the question and the answer about the thext problem I have faced (the No executable found matching command "dotnet-ef" error).

And here is the solution for the next one (the ... violates the constraint of type 'TContext' error)




回答2:


For me it is located at 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

More details : 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 -

C:\Users\anike>dotnet --version
2.1.4



回答3:


dotnet.exe is located in

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.

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.

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.




回答4:


For windows the reason was that it need to run from a Command prompt outside from visual studio. execute this command in command prompt,

dotnet run

then application run in https://localhost:5001




回答5:


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.



来源:https://stackoverflow.com/questions/42588392/where-is-the-dotnet-command-executable-located-on-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!