How to open Visual Studio Solution File from the Command Prompt
Asked Answered
C

4

39

Today I was in the Windows Command Prompt after doing a git clone https://...MySolution.git and wanted to open the .sln (i.e., solution file) from the new directory of the cloned repo.

What is the command to open this new solution in Visual Studio? Suppose the relative path is /MySolution/MySolution.sln

Cesena answered 20/6, 2017 at 17:12 Comment(2)
"....unless they directly involve tools used primarily for programming"..... Did I miss something or is Visual Studio used for writing poetry nowadays? I nominated this question for reopen!Meteorite
If you have mutliple versions of Visual Studio installed and want to open the solution file using a specific version of VS then you can pass the solution path directly to the devenv.exe: "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe" "D:\some\path\myapp.sln"Meteorite
C
103

If you haven't done cd MySolution but are still in the directory from which you did the git clone just type

start MySolution/MySolution.sln and hit Enter.

This will open whatever version of Visual Studio you currently have set to open with .sln files in Windows.

Cesena answered 20/6, 2017 at 17:12 Comment(1)
Also, start "vs exe path" "solution path" does not require changing directories as a pre-requisite e.g. start "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\devenv.exe" "C:\Code\HelloWorld\HelloWorld.sln"Sebiferous
O
6

Actually, you can also do directly \MySolution\MySolution.sln or .\MySolution\MySolution.sln and the solution will be opened.

I've been using it in CMD and Powershell with no problem.

Oto answered 10/4, 2021 at 4:9 Comment(1)
Welcome to SO Cristian. Yeah, on PowerShell the Tab autocomplete works well for these, so good times. As you said they work on CMD as well but the Tab Autocomplete doesn't work for the second half, i.e. \MyS + Tab doesn't resolve to \MySolution.sln, but it does when when you prefix start .... CMD just isn't smart enough :)Cesena
S
3

If you don't mind using PowerShell, you should try WhatsNew. Once installed, you can just type sln to open the solution file in that directory.

Snout answered 24/7, 2019 at 0:49 Comment(0)
T
1

As mentioned in some of the answers, you can directly launch sln-files from the command line, i.e.

MySolution\MySolution.sln

The fastest way to start a solution is to take advantage of the tab-completion. Note that this only works if you have only one solution-file in the folder.

If you are in the solution folder:

*slntabenter

If you are not in the solution folder:

MySolution\*slntabenter

Or depending on your location you can tab-complete the solution folder as well:

MySoltab\*slntabenter

This works in PowerShell as well with the following differences:

  • the backslash is automatically inserted upon doing tab-completion on a folder
  • you can use backslash or slash to mark a folder path
Thurible answered 23/10, 2023 at 8:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.