Using the command line from within Visual Studio

2020-02-11 18:04发布

I'd like to have a tool window in Visual Studio that allows me to type command line things (e.g. git stash, npm install, etc.) in the current project's working directory. Something like this in Eclipse.

I can't find any such option in any of the menus, but admittedly they're labyrinthine. I tried looking through the Visual Studio gallery, but no dice either. Any extension or hidden option that would give me this?

PowerShell would probably also work, as from what I understand that's a superset of the regular shell.

4条回答
男人必须洒脱
2楼-- · 2020-02-11 18:28

There is a command window in Visual Studio (CTRL + ALT + A) or (View -> OtherWindows -> Command Window)

You can then use the shell command to run external executables

The syntax is:

shell [/command] [/output] [/dir:folder] path [args]
查看更多
混吃等死
3楼-- · 2020-02-11 18:33

In Visual Studio 11, the NuGet Package Manager Console is a fully featured PowerShell console. You can do all kinds of things there, including file system operations, git/hg/svn/tfs commands, etc.

You also can customize the experience with a special PowerShell profile called NuGet_profile.ps1.

Installing the NuGet VSIX from the Visual Studio gallery will get you a similar experience in VS2010 if I'm not mistaken.

查看更多
混吃等死
4楼-- · 2020-02-11 18:47

You can download PowerConsole from the Visual Studio extensions gallery.

查看更多
Viruses.
5楼-- · 2020-02-11 18:48

For anyone that comes across this in 2018+, there is now also the Whack Whack Terminal extension from Microsoft's Daniel Griffen (@dgriffen on GitHub), which gives you exactly what you were looking for.

Whack Whack Terminal is a terminal emulator for Visual Studio 2017. Unlike other terminals for VS, Whack Whack Terminal is fully interactive. Users can launch interactive git commits, vim, or almost any other command line utility.

The default terminal is powershell and it can be opened with the shortcut chord "Ctrl+\, Ctrl+\".

CMD and WSLBash are also available terminal choices.

It's also open source! You can find the source code at Microsoft/WhackWhackTerminal on GitHub.

查看更多
登录 后发表回答