DevOps How To's Visual Studio

Visual Studio Code Remote on Windows Subsystem on Linux

The Remote – WSL extension extension lets you use the Windows Subsystem for Linux (WSL) as your full-time development environment right from VS Code. This new, optimized support lets you:

  • Use Windows to develop in a Linux based environment, using Linux specific toolchains and utilities.
  • Edit files located in WSL or the mounted Windows filesystem (e.g. /mnt/c).
  • Run and debug your Linux based applications on Windows, in VS Code.

Remote – WSL runs commands and extensions directly in WSL so you don’t have to worry about pathing issues, binary compatibility, or other cross-OS challenges. You’re able to use VS Code in WSL just as you would from Windows.

demo

Installation

  1. Install VS Code or VS Code Insiders and this extension.

    Note: When prompted to Select Additional Tasks during installation, be sure to check the Add to PATH option so you can easily open a folder in WSL using the code or code-insiders command.

  2. Install the Windows Subsystem for Linux along with your preferred Linux distribution.

    Note: WSL2 support is experimental. Also, extensions installed in Alpine Linux may not work due to glibc dependencies in native code inside the extension. See the Remote Development and Linux article for details.

Working with Git? Here are two tips to consider:

  • If you are working with the same repository in WSL and Windows, be sure to set up consistent line endings. See tips and tricks to learn how.
  • You can also avoid passwords by configuring WSL to use the Windows Git credential manager. See tips and tricks to for details.

Getting started

Follow the step-by-step tutorial or if you already have WSL running:

  1. Follow the installation steps above.
  2. Open a WSL terminal for your installed distribution (e.g. Ubuntu 18.04 LTS)
  3. Go to any folder and type: code .

Or you can:

  1. Start VS Code.
  2. Press F1, enter Remote-WSL: New Window, and hit enter.
  3. Use the File menu to open your folder.

VS Code will set up the environment and a new VS Code window will appear with the contents of the WSL folder!

Another way to learn what you can do with the extension is to browse the commands it provides. Press F1 to bring up the Command Palette and type in Remote-WSL for a full list.

Command palette

You can also click on the Remote “Quick Access” status bar item in the lower left corner to get a list of the most common commands.

Quick actions status bar item

Post Comment