Skip to content
| Marketplace
Sign in
Visual Studio>Tools>.NET Core Debugging with WSL 2 - Preview

.NET Core Debugging with WSL 2 - Preview

Preview

Microsoft

|
8,109 installs
| (5) | Free
Run and debug your .NET Core console and web applications in WSL 2.

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”
    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 runtime https://aka.ms/WslDotNet
  • Curl: https://curl.haxx.se/

Configuring your WSL 2 debugging experience:

Example launch Profile:

"WSL 2": {
    "commandName": "WSL2",
    "launchBrowser": true,
    "launchUrl": "https://localhost:5001",
    "environmentVariables": {
        "ASPNETCORE_URLS": "https://localhost:5001;http://localhost:5000",
        "ASPNETCORE_ENVIRONMENT": "Development"
    },
    "distributionName": ""
}

Supported Launch Profile Settings:

Setting Use Default
commandName Must be WSL2 WSL2
distributionName Name of the distribution to run in, or "" to use the default distribution. ""
executablePath Path to run dotnet
commandLineArgs Arguments to pass to executablePath The projects output assembly.
workingDirectory The directory in which to start executablePath For ASP.NET Core web apps, the project folder; for .NET Core console Apps, the output folder.
environmentVariables List of environment variables to set for executablePath. null
launchBrowser Whether or not to launch a browser. false
launchUrl Url 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.
  • Contact us
  • Jobs
  • Privacy
  • Terms of use
  • Trademarks
© 2023 Microsoft