Add Developer PowerShell and Developer Command Prompt Generator #5367

Closed
opened 2026-01-31 00:11:39 +00:00 by claunia · 30 comments
Owner

Originally created by @aetos382 on GitHub (Dec 3, 2019).

Description of the new feature/enhancement

Developer PowerShell and Developer Command Prompt are installed with VS 2019.
I’d like to add these profiles automatically when installing Windows Terminal on a machine with VS 2019 installed.
I think this is useful for developers using Visual Studio.

Originally created by @aetos382 on GitHub (Dec 3, 2019). # Description of the new feature/enhancement Developer PowerShell and Developer Command Prompt are installed with VS 2019. I’d like to add these profiles automatically when installing Windows Terminal on a machine with VS 2019 installed. I think this is useful for developers using Visual Studio.
Author
Owner

@ffes commented on GitHub (Jan 8, 2020):

Maybe they should just be added to https://github.com/microsoft/terminal/blob/master/doc/user-docs/ThirdPartyToolProfiles.md

This could be the VS 2019 CMD, Community Edition

{
  "commandline": "cmd.exe /k \"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools/VsDevCmd.bat\"",
  "icon": "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png",
  "name": "Developer CMD for VS 2019"
},

And this for the VS 2019 Powershell, Community Edition

{
  "commandline": "powershell.exe -noe -c \"&{Import-Module \"\"\"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools/Microsoft.VisualStudio.DevShell.dll\"\"\"; Enter-VsDevShell 9be17693}\"",
  "icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png",
  "name": "Developer PowerShell for VS 2019"
},

Both based on the start menu entries added by VS setup. They work fine for me.

@ffes commented on GitHub (Jan 8, 2020): Maybe they should just be added to https://github.com/microsoft/terminal/blob/master/doc/user-docs/ThirdPartyToolProfiles.md This could be the VS 2019 CMD, Community Edition ```json { "commandline": "cmd.exe /k \"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools/VsDevCmd.bat\"", "icon": "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png", "name": "Developer CMD for VS 2019" }, ``` And this for the VS 2019 Powershell, Community Edition ```json { "commandline": "powershell.exe -noe -c \"&{Import-Module \"\"\"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/Tools/Microsoft.VisualStudio.DevShell.dll\"\"\"; Enter-VsDevShell 9be17693}\"", "icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png", "name": "Developer PowerShell for VS 2019" }, ``` Both based on the start menu entries added by VS setup. They work fine for me.
Author
Owner

@ghost commented on GitHub (Jan 16, 2020):

They work fine for me.

For me Developer PowerShell for VS 2019 is generating an error on startup:

Enter-VsDevShell : 9be17693
No linha:1 caractere:132
+ ... ools/Microsoft.VisualStudio.DevShell.dll"; Enter-VsDevShell 9be17693}
+                                                ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Enter-VsDevShell], ItemNotFoundException
    + FullyQualifiedErrorId : VsInstallationNotFound,Microsoft.VisualStudio.DevShell.Commands.EnterVsDevShellCommand
@ghost commented on GitHub (Jan 16, 2020): > They work fine for me. For me Developer PowerShell for VS 2019 is generating an error on startup: ``` Enter-VsDevShell : 9be17693 No linha:1 caractere:132 + ... ools/Microsoft.VisualStudio.DevShell.dll"; Enter-VsDevShell 9be17693} + ~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Enter-VsDevShell], ItemNotFoundException + FullyQualifiedErrorId : VsInstallationNotFound,Microsoft.VisualStudio.DevShell.Commands.EnterVsDevShellCommand ```
Author
Owner

@ghost commented on GitHub (Jan 16, 2020):

Gotcha. Actually the profile provided by @ffes work as expected, since you change the identifier after Enter-VsDevShell to the identifier in Developer PowerShell for VS 2019 shortcut. Mine, for example, is 4704b565.

image

@ghost commented on GitHub (Jan 16, 2020): Gotcha. Actually the profile provided by @ffes work as expected, since you change the identifier after `Enter-VsDevShell` to the identifier in Developer PowerShell for VS 2019 shortcut. Mine, for example, is `4704b565`. ![image](https://user-images.githubusercontent.com/53820433/72925634-c968c580-3d31-11ea-90f4-f2a0674df40e.png)
Author
Owner

@aetos382 commented on GitHub (Jan 22, 2020):

Yes. If you want to add a profile for yourself, you need to get the instance ID from the shortcut in the start menu and set it on the command line.
Windows Terminal has a mechanism to dynamically generate profiles.
I think the VSSetup PowerShell module will help implement Developer Console Profile Generator.
https://github.com/microsoft/vssetup.powershell/tree/develop/src/VSSetup.PowerShell

@aetos382 commented on GitHub (Jan 22, 2020): Yes. If you want to add a profile for yourself, you need to get the instance ID from the shortcut in the start menu and set it on the command line. Windows Terminal has a mechanism to dynamically generate profiles. I think the VSSetup PowerShell module will help implement Developer Console Profile Generator. https://github.com/microsoft/vssetup.powershell/tree/develop/src/VSSetup.PowerShell
Author
Owner

@Greyze commented on GitHub (May 22, 2020):

I have this setup;

image

I had to create the icon besides just adding the profile. It would be great if all the dev prompts with appropriate icons were added by default (VS2017, VS2019 etc).

@Greyze commented on GitHub (May 22, 2020): I have this setup; ![image](https://user-images.githubusercontent.com/1690930/82687047-b10ca700-9c4e-11ea-9ff4-3872ff042f2f.png) I had to create the icon besides just adding the profile. It would be great if all the dev prompts with appropriate icons were added by default (VS2017, VS2019 etc).
Author
Owner

@Hummer311 commented on GitHub (Jun 23, 2020):

For the Powershell configuration, I've used the following. So far, so good.

,
{
    "commandline": "powershell.exe -noe -c \"&{ install-module vssetup -Scope currentuser; $i=(get-vssetupinstance); $i; Import-Module \"\"\"$($i.InstallationPath)/Common7/Tools/Microsoft.VisualStudio.DevShell.dll\"\"\"; Enter-VsDevShell $i.Instanceid;}\"",
    "icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png",
    "name": "VS2019 Powershell"
}
@Hummer311 commented on GitHub (Jun 23, 2020): For the Powershell configuration, I've used the following. So far, so good. ``` , { "commandline": "powershell.exe -noe -c \"&{ install-module vssetup -Scope currentuser; $i=(get-vssetupinstance); $i; Import-Module \"\"\"$($i.InstallationPath)/Common7/Tools/Microsoft.VisualStudio.DevShell.dll\"\"\"; Enter-VsDevShell $i.Instanceid;}\"", "icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png", "name": "VS2019 Powershell" } ```
Author
Owner

@Evangelink commented on GitHub (Jun 29, 2020):

The following link https://docs.microsoft.com/visualstudio/install/tools-for-managing-visual-studio-instances helped me to find the instance ID (I have been using the vswhere command)

@Evangelink commented on GitHub (Jun 29, 2020): The following link https://docs.microsoft.com/visualstudio/install/tools-for-managing-visual-studio-instances helped me to find the instance ID (I have been using the `vswhere` command)
Author
Owner

@akunzai commented on GitHub (Jun 30, 2020):

The Developer PowerShell profile that using vswhere command.

{
  "name": "Developer PowerShell",
  "commandline": "powershell.exe -NoExit -Command \"&{ $vsInstallPath=& \"${env:ProgramFiles(x86)}/'Microsoft Visual Studio'/Installer/vswhere.exe\" -prerelease -latest -property installationPath; Import-Module \"$vsInstallPath/Common7/Tools/Microsoft.VisualStudio.DevShell.dll\"; Enter-VsDevShell -VsInstallPath $vsInstallPath -SkipAutomaticLocation }\"",
  "icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png"
}
@akunzai commented on GitHub (Jun 30, 2020): The `Developer PowerShell` profile that using `vswhere` command. ```json { "name": "Developer PowerShell", "commandline": "powershell.exe -NoExit -Command \"&{ $vsInstallPath=& \"${env:ProgramFiles(x86)}/'Microsoft Visual Studio'/Installer/vswhere.exe\" -prerelease -latest -property installationPath; Import-Module \"$vsInstallPath/Common7/Tools/Microsoft.VisualStudio.DevShell.dll\"; Enter-VsDevShell -VsInstallPath $vsInstallPath -SkipAutomaticLocation }\"", "icon": "ms-appx:///ProfileIcons/{61c54bbd-c2c6-5271-96e7-009a87ff44bf}.png" } ```
Author
Owner

@patrikhuber commented on GitHub (Jul 14, 2020):

Hi,

I'm extremely interested in this. How can I open an "x64 Native Tools Command Prompt for VS 2019" with Windows Terminal? Note that this is slightly (but importantly) different from the "Developer Command Prompt for VS 2019".

If that was available from the Windows Terminal dropdown menu (with a nice icon) like in @Greyze's screenshot above, that would be even more amazing.

@patrikhuber commented on GitHub (Jul 14, 2020): Hi, I'm extremely interested in this. How can I open an "x64 Native Tools Command Prompt for VS 2019" with Windows Terminal? Note that this is slightly (but importantly) **different** from the "Developer Command Prompt for VS 2019". If that was available from the Windows Terminal dropdown menu (with a nice icon) like in @Greyze's screenshot above, that would be even more amazing.
Author
Owner

@huoyaoyuan commented on GitHub (Jul 15, 2020):

@patrikhuber You can right click the .lnk in start menu, and view what parameters it uses in the details, and compare between them.

@huoyaoyuan commented on GitHub (Jul 15, 2020): @patrikhuber You can right click the `.lnk` in start menu, and view what parameters it uses in the details, and compare between them.
Author
Owner

@patrikhuber commented on GitHub (Jul 15, 2020):

@huoyaoyuan: It shows Target: as:

%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
@patrikhuber commented on GitHub (Jul 15, 2020): @huoyaoyuan: It shows `Target:` as: ``` %comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" ```
Author
Owner

@patrikhuber commented on GitHub (Jul 15, 2020):

Modifying the snippet posted here https://github.com/microsoft/terminal/blob/master/doc/user-docs/ThirdPartyToolProfiles.md#developer-command-prompt-for-visual-studio works for me:

{
	"name": "x64 Native Tools Command Prompt for VS 2019",
	"commandline": "%comspec% /k \"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvars64.bat\"",
	"startingDirectory": "%USERPROFILE%",
	"icon": "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png"
}

Thank you!

@patrikhuber commented on GitHub (Jul 15, 2020): Modifying the snippet posted here https://github.com/microsoft/terminal/blob/master/doc/user-docs/ThirdPartyToolProfiles.md#developer-command-prompt-for-visual-studio works for me: ``` { "name": "x64 Native Tools Command Prompt for VS 2019", "commandline": "%comspec% /k \"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvars64.bat\"", "startingDirectory": "%USERPROFILE%", "icon": "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png" } ``` Thank you!
Author
Owner

@patrikhuber commented on GitHub (Jul 18, 2020):

Is there any way of setting this to the Visual Studio 2019 icon? I tried this, but it (expectedly) doesn't work:

"icon": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\Common7\\IDE\\devenv.exe"

Do I have to extract the icon from the .exe using a 3rd-party tool, or is there an easier way?

The docs don't mention anything https://docs.microsoft.com/en-us/windows/terminal/customize-settings/profile-settings#icon.

@patrikhuber commented on GitHub (Jul 18, 2020): Is there any way of setting this to the Visual Studio 2019 icon? I tried this, but it (expectedly) doesn't work: ``` "icon": "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\Common7\\IDE\\devenv.exe" ``` Do I have to extract the icon from the .exe using a 3rd-party tool, or is there an easier way? The docs don't mention anything https://docs.microsoft.com/en-us/windows/terminal/customize-settings/profile-settings#icon.
Author
Owner

@Greyze commented on GitHub (Jul 18, 2020):

Sadly there isn't a convenient way for that to automatically be added. I had to work around it.

I downloaded the VS2019 icon from the microsoft website. I'll add it here for you:

vs2019-32

I then dropped that image file into the terminals installation directory/RoamingState folder. Since I installed Terminal from the MS Store my folder is:
C:\Users\*\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\RoamingState

Lastly in the settings.json, i added the icon with this path:
"icon": "ms-appdata:///roaming/vs2019-32.png"

You should be good to go now. Obviously tweak the paths to your preferred choice. For clarity heres my whole settings block for VS2019 which gives you the terminal you saw in my image above:

{
    "acrylicOpacity": 0.75,
    "commandline": "cmd.exe /k \"C://Program Files (x86)//Microsoft Visual Studio//2019//Enterprise//Common7//Tools//VsDevCmd.bat\"",
    "guid": "{184f02e0-01c0-495e-9d97-b2467ec16958}",
    "historySize": 9001,
    "icon": "ms-appdata:///roaming/vs2019-32.png",
    "name": "Developer Command Prompt for VS2019",
    "startingDirectory": "%USERPROFILE%",
    "useAcrylic": true
},
@Greyze commented on GitHub (Jul 18, 2020): Sadly there isn't a convenient way for that to automatically be added. I had to work around it. I downloaded the VS2019 icon from the microsoft website. I'll add it here for you: ![vs2019-32](https://user-images.githubusercontent.com/1690930/87851194-4befcd80-c8ee-11ea-8741-b55c7c879563.png) I then dropped that image file into the terminals installation directory/RoamingState folder. Since I installed Terminal from the MS Store my folder is: `C:\Users\*\AppData\Local\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\RoamingState` Lastly in the settings.json, i added the icon with this path: `"icon": "ms-appdata:///roaming/vs2019-32.png"` You should be good to go now. Obviously tweak the paths to your preferred choice. For clarity heres my whole settings block for VS2019 which gives you the terminal you saw in my image above: ``` { "acrylicOpacity": 0.75, "commandline": "cmd.exe /k \"C://Program Files (x86)//Microsoft Visual Studio//2019//Enterprise//Common7//Tools//VsDevCmd.bat\"", "guid": "{184f02e0-01c0-495e-9d97-b2467ec16958}", "historySize": 9001, "icon": "ms-appdata:///roaming/vs2019-32.png", "name": "Developer Command Prompt for VS2019", "startingDirectory": "%USERPROFILE%", "useAcrylic": true }, ```
Author
Owner

@patrikhuber commented on GitHub (Jul 19, 2020):

@Greyze Thanks a lot, that's great! :)

@patrikhuber commented on GitHub (Jul 19, 2020): @Greyze Thanks a lot, that's great! :)
Author
Owner

@patrikhuber commented on GitHub (Jul 19, 2020):

One can also extract the .ico from devenv.exe, with Visual Studio, without any third party tool. Visual Studio => Open => File... => devenv.exe => expand "Icon" => right-click on the one you want, "Export". The .ico also works as "icon" for Windows Terminal.

@patrikhuber commented on GitHub (Jul 19, 2020): One can also extract the .ico from `devenv.exe`, with Visual Studio, without any third party tool. Visual Studio => Open => File... => devenv.exe => expand "Icon" => right-click on the one you want, "Export". The .ico also works as `"icon"` for Windows Terminal.
Author
Owner

@anf commented on GitHub (Dec 29, 2020):

Alright, so this is my configuration, works like a charm:

{
    "guid": "{1748ecca-abdd-4aa4-bcc4-9fca0d045be5}",
    "name": "VS Developer PowerShell",
    "commandline": "powershell.exe -NoExit -Command \"&{ $vsInstallPath=& \"${env:ProgramFiles(x86)}/'Microsoft Visual Studio'/Installer/vswhere.exe\" -prerelease -latest -property installationPath; Import-Module \"$vsInstallPath/Common7/Tools/Microsoft.VisualStudio.DevShell.dll\"; Enter-VsDevShell -VsInstallPath $vsInstallPath -SkipAutomaticLocation }\"",
    "icon": "https://devblogs.microsoft.com/wp-content/uploads/sites/4/2019/06/vs-for-mac-logo-caption2.png",
    "startingDirectory": "%USERPROFILE%",
    "hidden": false
},

I believe this will work for other editions as well. And for the icon, it gets cached the first time it's downloaded, I think.
image

It will get added soon, but, here you go anyways.

@anf commented on GitHub (Dec 29, 2020): Alright, so this is my configuration, works like a charm: ```json { "guid": "{1748ecca-abdd-4aa4-bcc4-9fca0d045be5}", "name": "VS Developer PowerShell", "commandline": "powershell.exe -NoExit -Command \"&{ $vsInstallPath=& \"${env:ProgramFiles(x86)}/'Microsoft Visual Studio'/Installer/vswhere.exe\" -prerelease -latest -property installationPath; Import-Module \"$vsInstallPath/Common7/Tools/Microsoft.VisualStudio.DevShell.dll\"; Enter-VsDevShell -VsInstallPath $vsInstallPath -SkipAutomaticLocation }\"", "icon": "https://devblogs.microsoft.com/wp-content/uploads/sites/4/2019/06/vs-for-mac-logo-caption2.png", "startingDirectory": "%USERPROFILE%", "hidden": false }, ``` I believe this will work for other editions as well. And for the icon, it gets cached the first time it's downloaded, I think. ![image](https://user-images.githubusercontent.com/68814933/103291570-10d3e900-49ba-11eb-85aa-16efbd0de2d6.png) It will get added soon, but, here you go anyways.
Author
Owner

@Robertschv commented on GitHub (Mar 17, 2021):

Alright, so this is my configuration, works like a charm:

{
    "guid": "{1748ecca-abdd-4aa4-bcc4-9fca0d045be5}",
    "name": "VS Developer PowerShell",
    "commandline": "powershell.exe -NoExit -Command \"&{ $vsInstallPath=& \"${env:ProgramFiles(x86)}/'Microsoft Visual Studio'/Installer/vswhere.exe\" -prerelease -latest -property installationPath; Import-Module \"$vsInstallPath/Common7/Tools/Microsoft.VisualStudio.DevShell.dll\"; Enter-VsDevShell -VsInstallPath $vsInstallPath -SkipAutomaticLocation }\"",
    "icon": "https://devblogs.microsoft.com/wp-content/uploads/sites/4/2019/06/vs-for-mac-logo-caption2.png",
    "startingDirectory": "%USERPROFILE%",
    "hidden": false
},

I believe this will work for other editions as well. And for the icon, it gets cached the first time it's downloaded, I think.
image

It will get added soon, but, here you go anyways.

What did you do? The "commandline" doesn't work in my PowerShell
The PowerShell doesn't like the "&" of $vsInstallPath=&

@Robertschv commented on GitHub (Mar 17, 2021): > Alright, so this is my configuration, works like a charm: > > ```json > { > "guid": "{1748ecca-abdd-4aa4-bcc4-9fca0d045be5}", > "name": "VS Developer PowerShell", > "commandline": "powershell.exe -NoExit -Command \"&{ $vsInstallPath=& \"${env:ProgramFiles(x86)}/'Microsoft Visual Studio'/Installer/vswhere.exe\" -prerelease -latest -property installationPath; Import-Module \"$vsInstallPath/Common7/Tools/Microsoft.VisualStudio.DevShell.dll\"; Enter-VsDevShell -VsInstallPath $vsInstallPath -SkipAutomaticLocation }\"", > "icon": "https://devblogs.microsoft.com/wp-content/uploads/sites/4/2019/06/vs-for-mac-logo-caption2.png", > "startingDirectory": "%USERPROFILE%", > "hidden": false > }, > ``` > > I believe this will work for other editions as well. And for the icon, it gets cached the first time it's downloaded, I think. > ![image](https://user-images.githubusercontent.com/68814933/103291570-10d3e900-49ba-11eb-85aa-16efbd0de2d6.png) > > It will get added soon, but, here you go anyways. What did you do? The "commandline" doesn't work in my PowerShell The PowerShell doesn't like the "&" of `$vsInstallPath=& `
Author
Owner

@anf commented on GitHub (Mar 17, 2021):

@Robertschv, that doesn't provide much detail for me to diagnose the cause of the issue, but from my experience, if you're using ui to do this, it jut won't work.

@anf commented on GitHub (Mar 17, 2021): @Robertschv, that doesn't provide much detail for me to diagnose the cause of the issue, but from my experience, if you're using ui to do this, it jut won't work.
Author
Owner

@Robertschv commented on GitHub (Mar 19, 2021):

@Robertschv, that doesn't provide much detail for me to diagnose the cause of the issue, but from my experience, if you're using ui to do this, it jut won't work.

This is what happens

Captura de pantalla de 2021-03-18 23-33-40

What to try this command in a Powershell, is there a way? I imagine is somewhat like this -->
&{ $vsInstallPath=& \"${env:ProgramFiles(x86)}/'Microsoft Visual Studio'/Installer/vswhere.exe\" -prerelease -latest -property installationPath; Import-Module \"$vsInstallPath/Common7/Tools/Microsoft.VisualStudio.DevShell.dll\"; Enter-VsDevShell -VsInstallPath $vsInstallPath -SkipAutomaticLocation }

@Robertschv commented on GitHub (Mar 19, 2021): > @Robertschv, that doesn't provide much detail for me to diagnose the cause of the issue, but from my experience, if you're using ui to do this, it jut won't work. This is what happens ![Captura de pantalla de 2021-03-18 23-33-40](https://user-images.githubusercontent.com/62678042/111728552-77db9e00-8843-11eb-9386-e0186abf9d24.png) What to try this command in a Powershell, is there a way? I imagine is somewhat like this --> `&{ $vsInstallPath=& \"${env:ProgramFiles(x86)}/'Microsoft Visual Studio'/Installer/vswhere.exe\" -prerelease -latest -property installationPath; Import-Module \"$vsInstallPath/Common7/Tools/Microsoft.VisualStudio.DevShell.dll\"; Enter-VsDevShell -VsInstallPath $vsInstallPath -SkipAutomaticLocation }`
Author
Owner

@anf commented on GitHub (Mar 19, 2021):

Oh Rob, that's not for normal PowerShell instances. I don't see the confusion either, it's easily translatable. If you just prefer hard coding though:

$vsInstallPath = "C:\Program Files (x86)\Microsoft Visual Studio\<Year>\<Edition>\" # Declare VS' installation path.
Import-Module "$vsInstallPath/Common7/Tools/Microsoft.VisualStudio.DevShell.dll" # Import the dll which allows access to VS' Developer PowerShell functions.
# Great, you now have access to it!
Enter-VsDevShell -VsInstallPath $vsInstallPath -SkipAutomaticLocation # Use this to boot it up.

However, I do recommend that you learn PowerShell as it'll help you a lot, automation will only make life easier.

Quick side note: You can also launch this batch file:

Batch file

@anf commented on GitHub (Mar 19, 2021): Oh Rob, that's not for normal PowerShell instances. I don't see the confusion either, it's easily translatable. If you just prefer hard coding though: ```ps1 $vsInstallPath = "C:\Program Files (x86)\Microsoft Visual Studio\<Year>\<Edition>\" # Declare VS' installation path. Import-Module "$vsInstallPath/Common7/Tools/Microsoft.VisualStudio.DevShell.dll" # Import the dll which allows access to VS' Developer PowerShell functions. # Great, you now have access to it! Enter-VsDevShell -VsInstallPath $vsInstallPath -SkipAutomaticLocation # Use this to boot it up. ``` However, I do recommend that you learn PowerShell as it'll help you a lot, automation will only make life easier. Quick side note: You can also launch this batch file: ![Batch file](https://user-images.githubusercontent.com/68814933/111731999-056ebc00-884b-11eb-8e2f-792bbf75c6f7.png)
Author
Owner

@Robertschv commented on GitHub (Mar 19, 2021):

Awesome, it worked!
Yes I am learning more about powershell
Thank you!

@Robertschv commented on GitHub (Mar 19, 2021): Awesome, it worked! Yes I am learning more about powershell Thank you!
Author
Owner

@SheepReaper commented on GitHub (Mar 30, 2021):

This also works with PS Core if installed (replace powershell.exe with pwsh)
Also unrelated, but helpful: Use -DevCmdArguments to select the desired toolchain: (I'm doing native compilation by default)
If you don't specify, it selects x86, x86

{
    "guid": "{d064db1b-5bf4-4497-98df-220e5b8da170}",
    "hidden": false,
    "name": "Developer PS (2019)",
    "commandline": "pwsh -noe -c \"&{ $vsInstallPath=& \"${env:ProgramFiles(x86)}/'Microsoft Visual Studio'/Installer/vswhere.exe\" -prerelease -latest -property installationPath; Import-Module \"$vsInstallPath/Common7/Tools/Microsoft.VisualStudio.DevShell.dll\"; Enter-VsDevShell -VsInstallPath $vsInstallPath -SkipAutomaticLocation -DevCmdArguments '-arch=amd64 -host_arch=amd64'}\"",
    "icon": "https://devblogs.microsoft.com/wp-content/uploads/sites/4/2019/06/vs-for-mac-logo-caption2.png",
    "startingDirectory": "%USERPROFILE%"
}
@SheepReaper commented on GitHub (Mar 30, 2021): This also works with PS Core if installed (replace powershell.exe with pwsh) Also unrelated, but helpful: Use `-DevCmdArguments` to select the desired toolchain: (I'm doing native compilation by default) If you don't specify, it selects x86, x86 ```json { "guid": "{d064db1b-5bf4-4497-98df-220e5b8da170}", "hidden": false, "name": "Developer PS (2019)", "commandline": "pwsh -noe -c \"&{ $vsInstallPath=& \"${env:ProgramFiles(x86)}/'Microsoft Visual Studio'/Installer/vswhere.exe\" -prerelease -latest -property installationPath; Import-Module \"$vsInstallPath/Common7/Tools/Microsoft.VisualStudio.DevShell.dll\"; Enter-VsDevShell -VsInstallPath $vsInstallPath -SkipAutomaticLocation -DevCmdArguments '-arch=amd64 -host_arch=amd64'}\"", "icon": "https://devblogs.microsoft.com/wp-content/uploads/sites/4/2019/06/vs-for-mac-logo-caption2.png", "startingDirectory": "%USERPROFILE%" } ```
Author
Owner

@maxnoe commented on GitHub (May 20, 2021):

With the new graphical settings editor, this is what I had to put into the command line field:

pwsh.exe -NoExit -Command " &{ $vsInstallPath=& "${env:ProgramFiles(x86)}\'Microsoft Visual Studio'\Installer\vswhere.exe" -prerelease -latest -property installationPath; Import-Module "$vsInstallPath/Common7/Tools/Microsoft.VisualStudio.DevShell.dll"; Enter-VsDevShell -VsInstallPath $vsInstallPath -SkipAutomaticLocation }"
@maxnoe commented on GitHub (May 20, 2021): With the new graphical settings editor, this is what I had to put into the command line field: ``` pwsh.exe -NoExit -Command " &{ $vsInstallPath=& "${env:ProgramFiles(x86)}\'Microsoft Visual Studio'\Installer\vswhere.exe" -prerelease -latest -property installationPath; Import-Module "$vsInstallPath/Common7/Tools/Microsoft.VisualStudio.DevShell.dll"; Enter-VsDevShell -VsInstallPath $vsInstallPath -SkipAutomaticLocation }" ```
Author
Owner

@anf commented on GitHub (May 20, 2021):

One thing I want to point out is that this will bring up the old PowerShell 5, if you want the new PowerShell Core 7, with multiple enhancements (which I do recommend), simply just change the powershell.exe part in whichever startup command you use to pwsh.exe, just make sure that it indeed is installed.

If you want to try out the new PowerShell Core, please visit the releases page. Fun fact; it's not only open source, but also cross-platform.

To verify that, run:

Get-Host | Select-Object Version
@anf commented on GitHub (May 20, 2021): One thing I want to point out is that this will bring up the old PowerShell 5, if you want the new PowerShell Core 7, with multiple enhancements (which I do recommend), simply just change the `powershell.exe` part in whichever startup command you use to `pwsh.exe`, just make sure that it indeed is installed. If you want to try out the new PowerShell Core, please visit the [releases page](https://github.com/PowerShell/PowerShell/releases/latest). Fun fact; it's not only open source, but also cross-platform. To verify that, run: ```ps1 Get-Host | Select-Object Version ```
Author
Owner

@maxnoe commented on GitHub (May 21, 2021):

This is a bit OT, but maybe you have an idea: when building a python binary wheel (using a cython extension) it works fine in the normal powershell (using the MSVC compiler) but in the "Developer Powershell" it fails to link against the python library and I get undefined symbols:

fibonacci.obj : error LNK2001: Unresolved external symbol "__imp__PyObject_SetAttr".
fibonacci.obj : error LNK2001: Unresolved external symbol "__imp__PyUnicode_InternFromString".
fibonacci.obj : error LNK2001: Unresolved external symbol "__imp__PyOS_snprintf".
fibonacci.obj : error LNK2001: Unresolved external symbol "__imp__PyThreadState_Get"
...

Any idea why explicitly opening the developer shell has this effect?

@maxnoe commented on GitHub (May 21, 2021): This is a bit OT, but maybe you have an idea: when building a python binary wheel (using a cython extension) it works fine in the normal powershell (using the MSVC compiler) but in the "Developer Powershell" it fails to link against the python library and I get undefined symbols: ``` fibonacci.obj : error LNK2001: Unresolved external symbol "__imp__PyObject_SetAttr". fibonacci.obj : error LNK2001: Unresolved external symbol "__imp__PyUnicode_InternFromString". fibonacci.obj : error LNK2001: Unresolved external symbol "__imp__PyOS_snprintf". fibonacci.obj : error LNK2001: Unresolved external symbol "__imp__PyThreadState_Get" ... ``` Any idea why explicitly opening the developer shell has this effect?
Author
Owner

@orcmid commented on GitHub (Jul 22, 2021):

@ANF-Studios :> Oh Rob, that's not for normal PowerShell instances. I don't see the confusion either, it's easily translatable. If you just prefer hard coding though:

$vsInstallPath = "C:\Program Files (x86)\Microsoft Visual Studio\<Year>\<Edition>\" # Declare VS' installation path.

I have a tangential concern that is also related to the discussion about developer commands.

Once upon a time in a galaxy far away, I could create a batch script that would discover the location of the Build Tools either for the latest version of VS or any specified older version. That was because the settings had a definition that could be discovered using the user settings that could be probed for in a .bat file.

Then that went away. It stopped some work of mine to provide simple compiles for reproducing builds by folks just getting into working on open-source Windows projects conducted on GitHub. I did not require use of Visual Studio, and one could do fine with a Community Edition or by just installing the Build Tools (and VS Code in all the editor examples).

I see that the start menu entries for later editions do have the entries for a few developer environments, and I had decided to find a way to mine that (or require it as a prerequisite before running my compile and other utility scripts).

I thought this @ANF-Studios example might lead to treasure. However, on my machine

C:/Program Files (x86)/Microsoft Visual Studio/ is empty except for folder Installer, although vswhere.exe in there might be handy. On the other hand, the Start Page "Developer Command Prompt for Visual Studio 2019" does the requisite magic, giving me

**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.6.0
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************

D:\crea\VSBuildTools\2019>

and I would be a happy camper if I could wind my way through that link to the batch files I want to run to set up a compile environment that my user/student/enthusiast has managed to install. (You can also see that I have the VS Build Tools installed elsewhere and that should not be a barrier.) Running this is a lot more than just setting VS160CMNTOOLS, which is all I need, although VSINSTALLDIR would also work as a starting point.

I am inspired to did deeper into this for my own purposes. I suspect I have also indicated that some of the presumed directory locations might not work for everyone.

@orcmid commented on GitHub (Jul 22, 2021): @ANF-Studios :> Oh Rob, that's not for normal PowerShell instances. I don't see the confusion either, it's easily translatable. If you just prefer hard coding though: > > ```powershell > $vsInstallPath = "C:\Program Files (x86)\Microsoft Visual Studio\<Year>\<Edition>\" # Declare VS' installation path. I have a tangential concern that is also related to the discussion about developer commands. Once upon a time in a galaxy far away, I could create a batch script that would discover the location of the Build Tools either for the latest version of VS or any specified older version. That was because the settings had a definition that could be discovered using the user settings that could be probed for in a `.bat` file. Then that went away. It stopped some work of mine to provide simple compiles for reproducing builds by folks just getting into working on open-source Windows projects conducted on GitHub. I did not require use of Visual Studio, and one could do fine with a Community Edition or by just installing the Build Tools (and VS Code in all the editor examples). I see that the start menu entries for later editions do have the entries for a few developer environments, and I had decided to find a way to mine that (or require it as a prerequisite before running my compile and other utility scripts). I thought this @ANF-Studios example might lead to treasure. However, on my machine `C:/Program Files (x86)/Microsoft Visual Studio/` is empty except for folder `Installer`, although `vswhere.exe` in there might be handy. On the other hand, the Start Page "Developer Command Prompt for Visual Studio 2019" does the requisite magic, giving me ``` ********************************************************************** ** Visual Studio 2019 Developer Command Prompt v16.6.0 ** Copyright (c) 2020 Microsoft Corporation ********************************************************************** D:\crea\VSBuildTools\2019> ``` and I would be a happy camper if I could wind my way through that link to the batch files I want to run to set up a compile environment that my user/student/enthusiast has managed to install. (You can also see that I have the VS Build Tools installed elsewhere and that should not be a barrier.) Running this is a lot more than just setting VS160CMNTOOLS, which is all I need, although VSINSTALLDIR would also work as a starting point. I am inspired to did deeper into this for my own purposes. I suspect I have also indicated that some of the presumed directory locations might not work for everyone.
Author
Owner

@SheepReaper commented on GitHub (Jul 22, 2021):

@ANF-Studios :> Oh Rob, that's not for normal PowerShell instances. I don't see the confusion either, it's easily translatable. If you just prefer hard coding though:

$vsInstallPath = "C:\Program Files (x86)\Microsoft Visual Studio\<Year>\<Edition>\" # Declare VS' installation path.

I have a tangential concern that is also related to the discussion about developer commands.

Once upon a time in a galaxy far away, I could create a batch script that would discover the location of the Build Tools either for the latest version of VS or any specified older version. That was because the settings had a definition that could be discovered using the user settings that could be probed for in a .bat file.

Then that went away. It stopped some work of mine to provide simple compiles for reproducing builds by folks just getting into working on open-source Windows projects conducted on GitHub. I did not require use of Visual Studio, and one could do fine with a Community Edition or by just installing the Build Tools (and VS Code in all the editor examples).

I see that the start menu entries for later editions do have the entries for a few developer environments, and I had decided to find a way to mine that (or require it as a prerequisite before running my compile and other utility scripts).

I thought this @ANF-Studios example might lead to treasure. However, on my machine

C:/Program Files (x86)/Microsoft Visual Studio/ is empty except for folder Installer, although vswhere.exe in there might be handy. On the other hand, the Start Page "Developer Command Prompt for Visual Studio 2019" does the requisite magic, giving me

**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.6.0
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************

D:\crea\VSBuildTools\2019>

and I would be a happy camper if I could wind my way through that link to the batch files I want to run to set up a compile environment that my user/student/enthusiast has managed to install. (You can also see that I have the VS Build Tools installed elsewhere and that should not be a barrier.) Running this is a lot more than just setting VS160CMNTOOLS, which is all I need, although VSINSTALLDIR would also work as a starting point.

I am inspired to did deeper into this for my own purposes. I suspect I have also indicated that some of the presumed directory locations might not work for everyone.

MS has moved to using the visual studio installer for all editions of VS as well as the build tools. A development novice would have to work hard to not use the VS installer to get their kits. The presumption here is that you will have vswhere available. For most novices you can also assume that things are installed in default locations. If you have the presence of mind to specify alternate install locations for things, then it's on you to know you have to locate vswhere somewhere else.

There's no magic bullet to locating installation directories unless you count wmi to at least find the VS Installer, but that seems like work to handle niche cases and not even all of them. Nevertheless, such a script to first locate vswhere and then use it, might have some value, but we've strayed from the topic of Windows Terminal and the simple JSON it provides to create new environments.

@SheepReaper commented on GitHub (Jul 22, 2021): > @ANF-Studios :> Oh Rob, that's not for normal PowerShell instances. I don't see the confusion either, it's easily translatable. If you just prefer hard coding though: > > > ```powershell > > $vsInstallPath = "C:\Program Files (x86)\Microsoft Visual Studio\<Year>\<Edition>\" # Declare VS' installation path. > > ``` > > I have a tangential concern that is also related to the discussion about developer commands. > > Once upon a time in a galaxy far away, I could create a batch script that would discover the location of the Build Tools either for the latest version of VS or any specified older version. That was because the settings had a definition that could be discovered using the user settings that could be probed for in a `.bat` file. > > Then that went away. It stopped some work of mine to provide simple compiles for reproducing builds by folks just getting into working on open-source Windows projects conducted on GitHub. I did not require use of Visual Studio, and one could do fine with a Community Edition or by just installing the Build Tools (and VS Code in all the editor examples). > > I see that the start menu entries for later editions do have the entries for a few developer environments, and I had decided to find a way to mine that (or require it as a prerequisite before running my compile and other utility scripts). > > I thought this @ANF-Studios example might lead to treasure. However, on my machine > > `C:/Program Files (x86)/Microsoft Visual Studio/` is empty except for folder `Installer`, although `vswhere.exe` in there might be handy. On the other hand, the Start Page "Developer Command Prompt for Visual Studio 2019" does the requisite magic, giving me > > ``` > ********************************************************************** > ** Visual Studio 2019 Developer Command Prompt v16.6.0 > ** Copyright (c) 2020 Microsoft Corporation > ********************************************************************** > > D:\crea\VSBuildTools\2019> > ``` > > and I would be a happy camper if I could wind my way through that link to the batch files I want to run to set up a compile environment that my user/student/enthusiast has managed to install. (You can also see that I have the VS Build Tools installed elsewhere and that should not be a barrier.) Running this is a lot more than just setting VS160CMNTOOLS, which is all I need, although VSINSTALLDIR would also work as a starting point. > > I am inspired to did deeper into this for my own purposes. I suspect I have also indicated that some of the presumed directory locations might not work for everyone. MS has moved to using the visual studio installer for all editions of VS as well as the build tools. A development _novice_ would have to work hard to _not_ use the VS installer to get their kits. The presumption here is that you _will_ have vswhere available. For most _novices_ you can also assume that things are installed in default locations. If you have the presence of mind to specify alternate install locations for things, then it's on you to know you have to locate vswhere somewhere else. There's no magic bullet to locating installation directories unless you count wmi to at least find the VS Installer, but that seems like _work_ to handle niche cases and not even all of them. Nevertheless, such a script to first locate vswhere and then use it, might have some value, but we've strayed from the topic of Windows Terminal and the simple JSON it provides to create new environments.
Author
Owner

@SheepReaper commented on GitHub (Sep 15, 2021):

Well Ok then. Was not expecting M$ to just up and add native support like that. But hey 👍🏼 🥳

@SheepReaper commented on GitHub (Sep 15, 2021): Well Ok then. Was not expecting M$ to just up and add native support like that. But hey 👍🏼 🥳
Author
Owner

@ghost commented on GitHub (Oct 20, 2021):

:tada:This issue was addressed in #7774, which has now been successfully released as Windows Terminal Preview v1.12.2922.0.🎉

Handy links:

@ghost commented on GitHub (Oct 20, 2021): :tada:This issue was addressed in #7774, which has now been successfully released as `Windows Terminal Preview v1.12.2922.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.12.2922.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#5367