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

working with git: archive
Aug 5, 2025

working with git: archive

read more →
Surprise Driven Development
Jul 10, 2025

Surprise Driven Development

read more →
What's in a .git? A Deep Dive into Git's Hidden Engine
Jun 3, 2025

What's in a .git? A Deep Dive into Git's Hidden Engine

read more →
Git Worktrees: Multiple Branches, Zero Context Switching
May 30, 2025

Git Worktrees: Multiple Branches, Zero Context Switching

read more →
Walking Back with Git: HEAD^ vs HEAD~ Demystified
May 29, 2025

Walking Back with Git: HEAD^ vs HEAD~ Demystified

read more →
New Project Release: Pride Flags
May 5, 2025

New Project Release: Pride Flags

read more →
the field notes

recently written