-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Developer PowerShell and Developer Command Prompt Generator #3821
Comments
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. |
For me Developer PowerShell for VS 2019 is generating an error on startup:
|
Gotcha. Actually the profile provided by @ffes work as expected, since you change the identifier after |
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. |
For the Powershell configuration, I've used the following. So far, so good.
|
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 |
The {
"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"
} |
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 You can right click the |
@huoyaoyuan: It shows
|
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:
Thank you! |
Is there any way of setting this to the Visual Studio 2019 icon? I tried this, but it (expectedly) doesn't work:
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. |
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: I then dropped that image file into the terminals installation directory/RoamingState folder. Since I installed Terminal from the MS Store my folder is: Lastly in the settings.json, i added the icon with this path: 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:
|
@Greyze Thanks a lot, that's great! :) |
One can also extract the .ico from |
@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 What to try this command in a Powershell, is there a way? I imagine is somewhat like this --> |
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: |
Awesome, it worked! |
This also works with PS Core if installed (replace powershell.exe with pwsh) {
"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%"
} |
With the new graphical settings editor, this is what I had to put into the command line field:
|
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 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 |
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:
Any idea why explicitly opening the developer shell has this effect? |
@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:
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 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
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. |
This commit adds dynamic profile generators for Visual Studio Developer Command Prompt (VS2017+) and Visual Studio Developer PowerShell (VS2019.2+) Tested manually by deploying locally. My local environment has four instances of VS installed, one VS2017 and multiple channels of VS2019. We're wrapping the COM Visual Studio Setup Configuration API to query for VS instances and retrieve the relevant properties. Two different namespaces are used so the end-user can turn off one or the other. For instance, end user may prefer to always use Developer PowerShell. ## Validation Steps Performed 1. Build locally using Visual Studio 2019 2. Deploy CascadiaPackage 3. Verify entries exist in profiles menu 4. Verify entries exist in settings.json 5. Open each profile 6. Validate start-in directory 7. Validate environment variables are as expected 8. Uninstall Windows Terminal - Dev package 9. Repeat. Closes #3821
Well Ok then. Was not expecting M$ to just up and add native support like that. But hey 👍🏼 🥳 |
🎉This issue was addressed in #7774, which has now been successfully released as Handy links: |
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.
The text was updated successfully, but these errors were encountered: