-
Notifications
You must be signed in to change notification settings - Fork 727
Windows Subsystem for Linux
With the Windows 10 Creators Update (Windows version 10.0.15063), you can use Visual Studio Code to debug .NET core applications on Windows Subsystem for Linux (WSL).
This page will walk you through the steps required to debug a .NET core application on WSL.
- Windows 10 Creators Update with Windows Subsystem for Linux and Bash installed.
- .NET Core on WSL
- Visual Studio Code
- Microsoft C# extension for VSCode.
Be sure to check the version of Ubuntu on WSL. The Windows 10 Creators Update comes with 16.04.2 LTS version of Ubuntu. You can confirm that by running the command below.
~$ cat /etc/os-release | grep -i version
VERSION="16.04.2 LTS (Xenial Xerus)"
VERSION_ID="16.04"
VERSION_CODENAME=xenial
If you had upgraded to Windows Creators update and already had WSL installed, you might still have Ubuntu 14 in the WSL. If the version is 14, run the following commands in a cmd prompt to reinstall and update WSL.
Note: These commands remove everything in your current WSL. Please be sure to save any files you wish to keep.
lxrun /uninstall /full
lxrun /install
Go to https://www.microsoft.com/net/core#linuxubuntu follow the instructions to install .NET core in WSL. You will need to follow the 16.04 instructions.
You can download a copy of the debugger with:
sudo apt-get install unzip
curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l ~/vsdbg
This will download and install the debugger at ~/vsdbg/vsdbg. This will be used later as the debuggerPath.
{
"name": ".NET Core WSL Launch",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "/mnt/c/temp/dotnetapps/wslApp/bin/Debug/netcoreapp1.1/wslApp.dll",
"args": [],
"cwd": "/mnt/c/temp/dotnetapps/wslApp",
"stopAtEntry": false,
"console": "internalConsole",
"pipeTransport": {
"pipeCwd": "${workspaceRoot}",
"pipeProgram": "bash.exe",
"pipeArgs": [ "-c" ],
"debuggerPath": "~/vsdbg/vsdbg"
}
}The sample application shown here was created in the Windows path C:\temp\dotnetapps\wslApp. WSL by default allows windows paths to be accessible through /mnt/<driveletter>/<path>, so the path above is accessible as /mnt/c/temp/dotnetapps/wslApp from WSL.
Note:
-
preLaunchTaskexecutesdotnet build, which builds the project on Windows. Since coreclr is cross-platform, the binary can be executed on WSL without any extra work. -
pipeProgramis set to bash.exe. -
debuggerPathpoints to vsdbg, the coreclr debugger.
{
"name": ".NET Core WSL Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickRemoteProcess}",
"pipeTransport": {
"pipeCwd": "${workspaceRoot}",
"pipeProgram": "bash.exe",
"pipeArgs": [ "-c" ],
"debuggerPath": "~/vsdbg/vsdbg",
"quoteArgs": true
}
}-
"processId": "${command:pickRemoteProcess}"lists the processes running on WSL using the pipe program. -
quoteArgswill quote any arguments and debugger commands with spaces if set totrue.
Note:
- Use
sourceFileMapto map sources if they are available in a different location than where they were built. - File and paths are case sensitive in Linux.
Documentation
- Change Log
- Main repo documentation.
- Branches and Releases
- Installing Pre-Releases
- Installing without internet connectivity
Configuration
- Configuring Snap installs of dotnet-sdk
- Configuring Arch Linux for Unity development
- Configuring Arch Linux for Razor development
- Installing the .NET Core Debugger on Arch Linux
Developer Guide