Since I’m starting to use Bash on Windows (WSL) more regularly, I added a quick way to launch Visual Studio 2017.
- Edit .bashrc and add the VS path (I’m obviously using Enterprise so your path may be different): export PATH=$PATH:”/mnt/c/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE”
- I chose to add an alias, so I also added this to my .bashrc: alias vs2017=devenv.exe
- Reload your shell: . /.bashrc
Now I can quickly pop open Visual Studio by using “vs2017”. For example, to open an existing solution I can navigate to the folder containing the .sln and simply type “vs2017 mysolutionfile.sln” at my bash prompt and VS2017 will fire up with that project loaded.
Here’s my .bashrc if you want to see the full file.
I’ve added this to my .bashrc file and changed the directory to be the same as my directory. restarted bash. then when I attempt to run ‘vs2017’ bash just says it doesnt recognise the command.. when wanting to open a file do you go to the directory and literllay just enter “vs2017 MySolutionhere.sln”? thats what I’m attemptuing to do currently
Yeah, that’s how it works. Taking the alias out of the equation, see if you can run devenv.exe MySolutionhere.sln. That will tell you if the path is set up right.
Is there a way to have it return control back to the terminal after it launches Visual Studio?
Add an ampersand (&) at the end. So “vs2017 &” will launch Visual Studio and return back in the terminal.
Thanks this was helpful I setup an alias like this
alias ~vs=’devenv.exe $(find -type f -iname “*sln”) &’
Just have to be in the root of my source control