Skip to main content
← back to field notes
One min readDevelopment

Loading Visual Studio environment in your default PowerShell profile

developmentpowershellenvironmentscripts

As a developer, you may want to load the Visual Studio environment in your default PowerShell profile. This is useful for debugging and developing.

If you aren't already aware, the easiest way to edit your profile is by using the profile variable. I use vscode, but you are free to use your favorite editor of choice.

code $PROFILE

The easiest way to do this used to be by calling VsDevCmd.bat from the tools directory. However, this can be fragile (and broken as of 2022-06-03). The below script is a bit more resilient and will load more quickly.

Update - 2020-06-07, corrected an issue where the profile wasn't restoring the current directory. added a push/pop

Updated profile script​

Microsoft.PowerShell_profile.ps1powershell
# use the vswhere command to find the location of Visual Studio, then append the tools path
$vspath = &"C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -latest -property installationpath
$tools = $vspath + "\Common7\Tools"

## launch the Visual Studio environment, and return to the current directory
Push-Location .
Import-Module $tools\Microsoft.VisualStudio.DevShell.dll
Enter-VsDevShell -VsInstallPath $VSPath
Pop-Location
field notes

you may also enjoy

more from this thread of thought

How to undo almost anything in git
Dec 3, 2026

How to undo almost anything in git

read more →
Git for designers and writers, without the terminal
Nov 25, 2026

Git for designers and writers, without the terminal

read more →
Notebooks, datasets and API keys: making git behave for data work
Nov 24, 2026

Notebooks, datasets and API keys: making git behave for data work

read more →
A git GUI for people who live in the terminal
Nov 23, 2026

A git GUI for people who live in the terminal

read more →
A git client your security team has nothing to ask about
Nov 20, 2026

A git client your security team has nothing to ask about

read more →
Three of me in one git log: keeping identities apart with includeIf
Nov 19, 2026

Three of me in one git log: keeping identities apart with includeIf

read more →
the field notes

recently written