Emulate The Visual Studio Command Prompt In PowerShell
The Visual Studio Command Prompt provided when you install Visual Studio adds lots of useful commands to the PATH of the current prompt. You don’t have to remember where msbuild.exe
or mstest.exe
are located just call the commands. However, Visual Studio only ships with a regular command prompt. There is no corresponding PowerShell command prompt.
All hope is not lost for PowerShell fans though. The Visual Studio Command Prompt works by calling the vcvarsall.bat
file that ships with Visual Studio to update the PATH
for the current session. We can take advantage of that same script when PowerShell starts to update the PATH
for the PowerShell session by modifying the default PowerShell profile.
First we need to open the PowerShell profile file for editing. This file is located at ~\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1
If you already have PowerShell open you can call start $PROFILE
from the prompt. This command will open the profile for you in your default editor.
Next paste these lines at the end of the file.
Save the file, and reopen a new PowerShell prompt. You should have a fully functioning Visual Studio Powershell Prompt.
Finally, if you don’t want to load the Visual Studio variables for every prompt, move the lines above to a file in your path and execute that file when you want the variables . thefilethathasthescriptabove.ps1
.
- Edit 6/7/2013 - Corrected typo in
Set-Item
line.