Visual studio: How to open a specific solution dir

2019-08-20 09:52发布

I want to open a specific solution (.sln) in visual studio directly from the command line.

Using the command, I tried

devenv "full-path-to-sln-file.sln"

but it didn't work.

How do I do this?

4条回答
走好不送
2楼-- · 2019-08-20 10:05

I wrote an open source application called OpenVSSolution to do exactly this.

Essentially:

  • Put this helper exe somewhere in your PATH
  • The exe scans the current directory for a .sln file
  • The exe opens devenv passing in the sln file

The explanation is on here: https://davemateer.com/coding/2018/11/14/Open-visual-studio-from-command-line.html

I find this incredibly useful and is how I open all solutions.

查看更多
放我归山
3楼-- · 2019-08-20 10:10

Try WhatsNew. From the readme:

Why fish around for Visual Studio solution files using Windows Explorer when you can find and launch them from your terminal window with just three little letters? Run sln (an alias for Open-Solution) to recursively search your current working directory for a solution file and launch it, if one is found.

查看更多
叼着烟拽天下
4楼-- · 2019-08-20 10:16

Use the full path to the devenv.exe executable and the full path to the sln solution file, both wrapped in quotes and with a space in between. If your solution file is in a network path, make sure that it does not require authentication before accessing the destination folder.

C:\Users\YourWindowsUser>"D:\Visual Studio\Common7\IDE\devenv.exe" "\\networkDirectory\profiles\Desktop\VisualStudioSolutions\Project999.sln"
查看更多
时光不老,我们不散
5楼-- · 2019-08-20 10:18

You can just use explorer.exe !! In your command line type in:

explorer mysolution.sln

查看更多
登录 后发表回答