Visual Studio Code ASP.NET Core Debugging on Ubuntu 16.04
Now, when you have dotnet installed, it's time to setup the debugger. If already have a project to debug, that's great. If not - download official samples from ASP.NET github repository (https://github.com/aspnet/cli-samples - remember to run dotnet restorein the project directory afterwards). After setting this up, just open project directory in VS Code.
First of all, you need Visual Studio Code C# extension. To install it, just press Ctrl+E inside VS Code and type:
ext install C#
After sucessful installation, editor will prompt you to restart. And now... another error! It says, that Ubuntu 16.04 is not supported by .NET Core Debugger. Or is it? ;]
To HACK this issue, go back to the terminal, and head to
/etc/
In this directory, there is a lot of files... And here comes the greatness of "everything-is-a-file" Linux philosophy: the /etc/ directory contains the following files:
os-release
lsb-release
Which as you might have guessed - store the information about Ubuntu version. Let's change all of the 16.04 to 14.04 and see what happens!
sudo nano os-release
edit the file, press Ctrl+O [ENTER] to save, Ctrl+X to exit
repeat the same procedure for the next file:
sudo nano lsb-release
I provide you my files if you are uncertain how they should look:
/etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=xenial
DISTRIB_DESCRIPTION="Ubuntu 14.04 LTS"
/etc/os-release
NAME="Ubuntu"
VERSION="14.04 LTS (Xenial Xerus)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 14.04 LTS"
VERSION_ID="14.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
UBUNTU_CODENAME=xenial
Go back to Visual Studio Code. Oh my goodness! .NET Core Debugger have installed! VS Code will also prompt you to add debug configuration file, click yes to generate it.
Debugging ASP.NET Core 1.0 on Ubuntu 16.04
The final step. Open debug view in Code and make sure that you have .NET Core Launch (console) selected as debug target.
Start debugging by pressing F5. Go back to your code, and mark breakpoint somewhere.The ultimate test - open web browser and hit localhost:5000 (or any other port if you have changed it)... drumroll please... Isn't it awesome?
I hope this post helped you to fully setup ASP.NET Core debugging on Ubuntu 16.04. Happy C# coding... on Linux!
No comments:
Post a Comment