Running dotnet command line within Visual Studio
The full version of Visual Studio is "Visual Studio", "Code" is what differentiates "Visual Studio Code".
As far as an integrated command line inside Visual Studio goes, the Package Manager Console is it. It's basically just powershell, with some addins from Visual Studio and any extensions or NuGet packages you have installed. It gets its name from the fact that it was introduced specifically for the management of NuGet packages, but was quickly co-opted by things like Entity Framework, and just continued to grow from there. Admittedly, Microsoft should probably consider rebranding it, but there's so much documentation, articles and tutorials out there that reference the "Package Manager Console", that it would probably actually create more confusion if they renamed it.
While you can run
dotnet
commands through it, I'd imagine the results would be a bit unpredictable. Perhaps I'm wrong here, as I've never even tried to do things likedotnet new
from the PMC, but the PMC is not really directory-based like a traditional console window. It's more contextual in nature, applying commands to target projects. I do know that things likedotnet restore
and such work fine, anddotnet new
may as well. You'll just have to try it.
That said, I tend to take an all or nothing approach with Visual Studio. It's a beast, and if you're going to install it and use it, you might as well use it. You can do everything you can do with dotnet
through the GUI. And, for those few times where you might need something special, you can pop a console window. If you want to do everything with dotnet
, Visual Studio quickly becomes overkill, and Visual Studio Code would probably be much more efficient for your workflow.
Update: Visual Studio 2019 16.6 now has it's own Terminal (Hoorray!). Check View -> Terminal or try to press Ctrl + `.
Old answer:
There are extensions for that. I tried BuiltinCmd and Whack Whack Terminal, the latter worked better for me. You can choose between CMD and PowerShell, all dotnet CLI commands works just fine.
While following a tutorial to update database, I had to run these commands
dotnet ef migrations add MaxLengthOnNames dotnet ef database update
in the command window of Visual studio, as per tutorial. When I opened this window in visual studio (View > Other Windows > Command Window) and attempted to run these commands, I received this error:
>dotnet ef migrations add MaxLengthOnNames
Command "dotnet" is not valid.
>dotnet ef database update
Command "dotnet" is not valid.
>
When I attempted to run them in Package Manager Console, this is the result I got:
No project was found. Change the current working directory or use the --project option.
Now, I googled it a bit and got the hint that I must run these commands in windows command prompt (opened by typing "cmd" in Windows start search). Steps are:
- Open windows command prompt
- Set your project directory as current directory
- run any dotnet command you need like I entered this: dotnet ef database update
- success