Visual Studio Wsl



Visual Studio Wsl

Visual Studio Wsl Python

The.NET Core Debugging with WSL 2 – Preview extension lets you run and debug your.NET Core console and web applications in WSL 2 from Visual Studio. This allows Windows developers targeting Linux production environments to have a higher fidelity local debugging experience. Get started with.NET Core Debugging with WSL 2. The wsl-install tool requires WSL 2 to already be enabled on Windows. If for some reason WSL 2 is not enabled, you can follow the WSL install documentation. You can also use the windowsfeature-enable tool for enabling any needed Windows Features. Are you a Windows developer interested in leveraging the power of Visual Studio to build and debug natively in WSL? Come learn about Visual Studio’s WSL supp. When using a remote connection, Visual Studio builds C Linux projects on the remote machine. It doesn't matter if it's a physical machine, a VM in the cloud, or WSL. To build the project, Visual Studio copies the source code to your remote Linux computer. Then, the code gets compiled based on.

Now included in Visual Studio 2019!

This extension is now available as an optional feature in Visual Studio 2019 v16.9 Preview 1 and will no longer be updated on the marketplace. To download the preview goto https://aka.ms/vspreview

The .NET Core Debugging with WSL 2 – Preview extension lets you run and debug your .NET Core console and web applications in WSL 2 from Visual Studio. This allows Windows developers targeting Linux production environments to have a higher fidelity local debugging experience.

Get started with .NET Core Debugging with WSL 2

  1. Open an ASP.NET Core web app or .NET Core console App
  2. Change the Launch Profile to “WSL 2”
  3. Press F5
    Note: If you want to verify that your code is running in WSL 2, you can check the value of Environment.OSVersion

Prerequisites

  • Visual Studio 2019 v16.6:https://aka.ms/vs
  • .NET Core Tools:https://get.dot.net
  • WSL 2:https://aka.ms/wsl
  • WSL 2 distribution:https://aka.ms/wslstore

Prerequisites for distributions other than Debian and Ubuntu

Only Debian and Ubuntu are tested and supported, but other distributions should work as long as you have installed:

  • .NET Core runtimehttps://aka.ms/WslDotNet
  • Curl:https://curl.haxx.se/

Configuring your WSL 2 debugging experience:

Example launch Profile:

Supported Launch Profile Settings:

SettingUseDefault
commandNameMust be WSL2WSL2
distributionNameName of the distribution to run in, or ' to use the default distribution.'
executablePathPath to rundotnet
commandLineArgsArguments to pass to executablePathThe projects output assembly.
workingDirectoryThe directory in which to start executablePathFor ASP.NET Core web apps, the project folder; for .NET Core console Apps, the output folder.
environmentVariablesList of environment variables to set for executablePath.null
launchBrowserWhether or not to launch a browser.false
launchUrlUrl to use for launching a browser.null

What's new in 0.2

  • Support for choosing the distribution to use.
  • Support for custom values of automount:root.
  • Removed the dependency on Debian's dpkg command.
  • Some smaller bug fixes.

Known Issues

  • [Only on Visual Studio 2019 v16.9 Preview 1] If a preview version of .NET 5.0 has been installed in the WSL distribution you will not be prompted to install the released version. To fix this you will need to manually install .NET 5.0 using the instructions here
  • Applications running in WSL 2 cannot access networking apps running on Windows through localhost (see https://docs.microsoft.com/en-us/windows/wsl/compare-versions#accessing-windows-networking-apps-from-linux-host-ip for mitigations).
  • Authenticating to Azure services using the credentials from VS is not supported. The easiest way to authenticate with Azure in your app in WSL 2 is to use Azure.Identity (1.2.0-preview.1 or newer), install the Azure CLI in your WSL 2 distribution and run az login.
  • ASP.Net Core development certificates are not trusted within WSL 2. Any service to service calls over HTTPS will need to handle allowing the untrusted development certificate when running locally.
  • Blazor Web Assembly Debugging is not currently supported.
  • The enabled key of the automount section in the wsl configuration file must be left at its default value of true.

Recently, I’ve published a blog post on how to set up the Windows Subsystem for Linux version 2 (WSL 2). I’m currently learning Ansible and I was searching for a solution that fits my needs in terms of usability, knowledge, etc. I’ve tested some Linux distributions, tried to connect remotely with my coding tool of choice, Visual Studio Code, but all were complex or didn’t work as expected. That’s the reason I gave WSL 2 a try.

Visual Studio Wsl2 Docker

I really like Visual Studio Code. It’s fast, supports a wide range of languages, and it’s free. Yes, free. And you don’t even need a registration nor a login to download it! VSCode also supports a variety of extensions. If it detects that you’re writing something in YAML, it might help you with a pop-up that there is an extension for it, for example, to properly highlight the syntax of that language. And that’s just one great example. With the combination of WSL 2 and VSCode, I’m able to write scripts (or playbooks in Ansible terms) and run them directly in the same tool. How cool is this?

Today, I’m going to show you how you can set up Visual Studio Code to use it with your already installed WSL 2 Linux distribution (at least when you read my previous blog post and followed the guide there).

Developing in WSL. The Visual Studio Code Remote - WSL extension lets you use the Windows Subsystem for Linux (WSL) as your full-time development environment right from VS Code. You can develop in a Linux-based environment, use Linux-specific toolchains and utilities, and run and debug your Linux-based applications all from the comfort of Windows. The extension runs commands and other extensions directly in WSL so you can edit files located in WSL.

Let’s dive into the setup now. I’m assuming that you’re doing this on the same computer / virtual machine as you installed WSL 2 already.

Visual studio wsl2
  1. Download Visual Studio Code either from its official website, or use Chocolatey to install VSCode:
    Download Visual Studio Code – Mac, Linux, Windows
    Chocolatey Software | Visual Studio Code 1.52.1
Visual Studio Wsl
  1. Open PowerShell / Windows Terminal and execute “wsl” to start your Linux Distribution.
  2. Open Windows Explorer and navigate to wsl$[your_distro]home[your_username].

    We will just create a folder here within Windows Explorer, where we then put files from VSCode. Let’s call this folder “ansible“.

  3. Now, start VSCode. You might get asked if you want to install the recommended extensions for WSL. Click “install”.
  4. We’re opening now the WSL folder from step 3 in VSCode.
    Click File => Open Folder… and navigate again to the WSL share from above.
  5. For the next step, we’re going to configure the WSL bash (the Linux CLI so to speak).
    Click File => Preferences => Settings
    Enter “terminal.integrated.shell.windows” into the search bar, the result should show up automatically.

    Click “Edit in settings.json
    If you just did a fresh installation of VSCode, then there should not be much in here. We’re free to change stuff.
    Change the code to:

    {
    'terminal.integrated.shell.windows': 'C:WindowsSystem32wsl.exe',
    'explorer.confirmDragAndDrop': false
    }

    Click File => Save or Ctrl + S to save the change.

  6. You can now restart VSCode. As soon as it’s open, you should already see the WSL bash in the Terminal window. Isn’t that cool?
  7. We’re going to use this bash right now to do some very basic settings in Linux.
    1. sudo apt update && sudo apt upgrade -y
      1. one-liner to update the local package repository cache and install the upgrades
    2. sudo apt dist-upgrade
      1. smart conflict resolution that intelligently handles changing dependencies with new versions of packages
    3. sudo apt autoremove
      1. removes non-used packages
  8. Next, we can install Git. We might use Git in the future to download/clone some code from online repositories, so it’s good to have it already installed.
    1. sudo apt install git -y
      1. At least in my setup, Ubuntu told me that it is already installed. Your mileage may vary.
Visual

And did I already mention that it is some pain in the back to create a numbered list in WordPress, which looks nice, and has images included? And I’m still not satisfied yet, dang it!

Check out the blog series for setting up WSL 2 and using it for Ansible:

Visual Studio Wsl Support

  • Part 1: Setting up Windows Subsystem for Linux Version 2 (WSL 2)
  • Part 2: Setting up Visual Studio Code for WSL 2