The PowerShell you know and love now with a side of Visual Studio

Ruben Rios

Ruben

While we know that many of you enjoy, and rely on the Visual Studio Command Prompt, some of you told us that you would prefer to have a PowerShell version of the tool. We are happy to share that in Visual Studio 2019 version 16.2, we added a new Developer PowerShell!

Using the new Developer PowerShell

We also added two new menu entries, providing quick access to not just the Developer PowerShell, but also for the Developer Command Prompt. These menu entries are located under Tools > Command Line.

C:\Users\rurios\AppData\Local\Microsoft\Windows\INetCache\Content.MSO\7DF5E1ED.tmp

Also, you can access the Developer Command Prompt and Developer PowerShell via the search (Ctrl +Q):

Selecting either of these tools, will launch them in their respective external windows, and with all the predefined goodness (e.g. preset PATHs and environment variables) you already rely on.

Opening them from Visual Studio automatically adjust their directories based on current solution or folder’s location. Additionally, If no solution or folder is open at the time of invocation, their directories are set based on the “Projects location” setting. This setting is located under Tools > Options > Locations.

Try it out and let us know what you think!

We’d love to know how it fits your workflow. Please reach out if you have any suggestions or comments around how we could further improve the experience. Send us your feedback via the Developer Community portal or via the Help > Send Feedback feature inside Visual Studio.

Ruben Rios
Ruben Rios

Program Manager 2, Visual Studio

Follow Ruben   

24 comments

  • Avatar
    Mark Zuber

    What about directly from the command line?  For cmd there’s vsdevcmd.bat and for a long time I’ve used a custom .ps1 script that runs that and parses out the environment variables into powershell.  Looking at the shortcut for the Developer Powershell for VS2019, I see this:  C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -NoExit -Command “& { Import-Module .\Common7\Tools\vsdevshell\Microsoft.VisualStudio.DevShell.dll; Enter-VsDevShell -InstanceId bb334830}”Do I just need to make my own .ps1 that runs the command there?  it would be really great to have a vsdev.ps1 shipped within Visual Studio itself so I can use vswhere to figure out the proper VS installation and then spin up the dev environment prompt without leaving powershell.It’s great to see powershell getting the attention it deserves here.  Thanks for the work!

    • Ruben Rios
      Ruben Rios

      Hi Mark! Yes, you can run it by using the command information you above. If you add that command information (e.g. Import-Module .\Common7\Tools\vsdevshell\Microsoft.VisualStudio.DevShell.dll; Enter-VsDevShell -InstanceId bb334830) to a custom script, you should be able to run it on a regular PowerShell instance.

    • Ruben Rios
      Ruben Rios

      Hi Retano! While I don’t have instructions to fully add a profile to the new Windows Terminal, you can manually add the additional functionality to a regular PowerShell instance by inputing the command used to run the Developer PowerShell.

      For example, go to the location of your Developer PowerShell shortcut (e.g. C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2019\Visual Studio Tools), open the shortcut Properties and look for the command information available under the shortcuts target information. In particular you want to copy the command that’s getting executed (e.g. “Import-Module \Common7\Tools\vsdevshell\Microsoft.VisualStudio.DevShell.dll; Enter-VsDevShell -InstanceId f86c8b33”). Once you have that information, add the full path to the module, enter that into the PowerShell instance in the Windows Terminal and you should be good to go.

      In my case (yours will vary based on your paths and VS instance information), I can get it running inside the new Windows Terminal by running this command:
      “Import-Module ‘C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Preview_master\\Common7\\Tools\\vsdevshell\\Microsoft.VisualStudio.DevShell.dll’; Enter-VsDevShell -InstanceId f86c8b33”

      Hope that helps!

  • Travis Illig
    Travis Illig

    This doesn’t seem to be compatible with PowerShell Core. I can import the Microsoft.VisualStudio.DevShell.dll module, but when I run Enter-VsDevShell it tells me:
    The satellite assembly named “Microsoft.VisualStudio.DevShell.resources.dll, PublicKeyToken=b03f5f7f11d5a3a” for fallback culture “en” either could not be found or could not be loaded. This is generally a setup problem. Please consider reinstalling or repairing the application.

    • Ruben Rios
      Ruben Rios

      Hi @Travis! Yes, we are aware of the lack of PowerShell Core support and while we don’t have any plans to share at the moment, we’ll continue monitoring feedback around this area and revisit things accordingly.

  • Avatar
    Wayne Hiller

    What we really need is for this same menu to be available when right clicking on a folder in the Solution explorer. When clicked the window would open to the selected folder. I have to just to folders so often to run npm or dotnet.

    • Ruben Rios
      Ruben Rios

      Thanks for the feedback @Wayne! We have plans to add a similar feature (e.g. solution explorer support) with a new related experience we’ll announce soon. Stay tuned! 🙂

  • Avatar
    Frank Hileman

    Just updated Visual Studio to 16.2.4, and the developer command prompt doesn’t work at all. It seems a specific version of powershell is needed. Cannot load DevShell.dll, … the assembly was built with a newer run-time than the currently loaded one. What are the pre-requisites?

Leave a comment