2

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?

hannes neukermans
  • 12,017
  • 7
  • 37
  • 56
  • Did you specify the full path to the sln file? Do you have multiple VS versions installed? Try to specify the full path to devenv.exe. – Peter Macej Apr 09 '18 at 07:58

6 Answers6

7

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

explorer mysolution.sln

hannes neukermans
  • 12,017
  • 7
  • 37
  • 56
2

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"
EzLo
  • 13,780
  • 10
  • 33
  • 38
1

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.

Dave Mateer
  • 6,588
  • 15
  • 76
  • 125
1

You can open a solution file with Visual Studio directly if you are within a folder that contains the solution file, looking for it recursively (Powershell 7.0) by doing the following:

Open powershell, type

echo $profile

Open up the location of your profile, save the below into it:

function vs
{
Get-ChildItem *.sln -Recurse | Invoke-Item
}

Then just type vs into a folder and it will go through the sub directories looking for the solution file and open one if found

0

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.

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

for macOs I just use:

open projectname.csproj

it will open it in visual studio 2019 for me

Andy
  • 1,190
  • 1
  • 11
  • 25