38

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

Eric D. Johnson
  • 10,219
  • 9
  • 39
  • 46
  • 1
    "....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! – Andreas Aug 03 '18 at 06:44
  • 4
    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"_ – Andreas Aug 03 '18 at 06:50

3 Answers3

99

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.

Eric D. Johnson
  • 10,219
  • 9
  • 39
  • 46
  • 2
    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"``` – gawkface Mar 03 '21 at 22:30
5

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.

  • 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 :) – Eric D. Johnson Apr 16 '21 at 14:16
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.

Nick Spreitzer
  • 10,242
  • 4
  • 35
  • 58