Powershell Visual Studio 2019

Powershell Visual Studio 2019

Aug 20, 2019 August 20th, 2019 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. Jul 06, 2019 Applies to Visual Studio, Tool-Making Requirements: Visual Studio, ConvertForm (Module) Introduction. Scripting, module creation, and tool-making are invaluable skills for any IT administrator- in IT Operations or elsewhere. The inherent problem with complex scripts and tools is the skills required to understand and use them.

Powershell Visual Studio 2019

PowerShell in Visual Studio Code. PowerShell is a task-based command-line shell and scripting language built on.NET, which provides a powerful toolset for administrators on any platform. The Microsoft PowerShell extension for Visual Studio Code provides rich language support and capabilities such as completions, definition tracking, and linting analysis for PowerShell versions 3, 4, 5, and 5. Windows Server 2016 / 2019 or Windows 10, 64-bit versions supported; 400MB free disk space; 2GB RAM.NET Framework 4.8.Net 5 for PowerShell 7; Visual Studio 2015-2019 Runtime; View the Manual Download the Manual.

Visual Studio recently got a new Developer PowerShell command prompt, which is super useful since it has all the environment variables properly set up to do things like msbuild from command line and have it pick the “right” MSBuild.

As a follow up to my post on Developer Command Prompt in Visual Studio Code Integrated Terminal, this is how you get the new powershell prompt in VS Code.

This time, however, I’ll add a twist: I recently learned that you can get PowerShell Core installed as a .NET Global Tool, which makes it super easy to install and run even on CI machines. You will want to get at least version 7.0.0 to get a key fix:

NOTE: yes, update will also install if it’s not installed. And it will ensure at least that version is installed. If you want to use this in CI, you will want to make sure the command never returns an error code by appending >nul dotnet tool list -g, say.

Powershell Visual Studio 2019 Tutorial

Powershell Visual Studio 2019

NOTE2: you’ll need at least .NET Core 3.1 for that version of the powershell global tool to work.

Now that you have the pwsh dotnet global tool, let’s configure it for VS Code to use by default in a Windows terminal. Open File Preferences Settings and click the very undiscoverable Open Settings (JSON) icon at the top-right of your window, right next to the left of the Split Editor icon, and add the following lines:

Things to note:

  1. You can access environment variables in your settings by just using ${env:}. .NET Core global tools live in that folder shown above
  2. The fancy looking Import-Module contains the install directory for your VS, so it will typically be ...2019[Enterprise Professional Communit Preview], unless you customize it at install time.
  3. The last line resets the settings for automation shells(i.e. running tasks), so that we don’t interfere with them.

    Due to what seems to be a bug or limitation of the automation shell, you will also need (for now?) need to add the following to your tasks.json to force the default shell to not pick the settings shellArgs, for each individual task:

    “options”: {

Like in my previous post, I still find the following two settings useful, if you want the same cursor style and blinking in the terminal as in the editor:

Finally, the default Ctrl+K keybinding to clear the terminal window won’t work in cmd.exe, just rendering a useless ^K, so I also set it to Ctrl+Shift+K instead via the File Preferences Keyboard Shortcuts menu by adding the following:

Visual Studio Community

See also Customizing Windows Terminal with Visual Studio tabs.