Visual Studio/Linux development

Recent versions of Visual Studio have included cross-platform support, notably for Android, iOS and now Linux. As Linux applications cannot (obviously) run natively on Windows, one can either


 * use another Linux machine
 * use

In this guide, we'll use the latter method as it's more 'native', though those wishing to use the former method can also use this guide.

Pre-requisites
You'll need
 * 1) Windows 10 (64-bit only)
 * 2) Visual Studio 2017 or later

Procedure
$ sudo apt update $ sudo apt install -y build-essential $ sudo apt install -y gdbserver $ sudo apt install -y openssh-server $ sudo ssh-keygen -A $ sudo service ssh start
 * 1) Install the Linux development workload from Visual Studio Installer if you already haven't.
 * 2) Install the Windows Subsystem from Linux tools and download a Linux flavour from the Windows Store of your choosing Here's an example guide. Set up the Linux configuration.
 * 3) Run the following commands on the Linux bash:
 * 1) Open   using a code editor; for example,  . Look for   and set it to yes.
 * 2) Start the SSH service:
 * 1) Open Visual Studio and create/import a Linux project: Linuxprojectvs1.PNG
 * 2) Open Cross-Platform Manager, and click Add. Enter the host name as localhost, port number as 22 and enter your UNIX username (not Windows!) and password. If you are not using Windows Subsystem for Linux, enter the host name of the Linux machine that you'll use instead of localhost. If all goes well, you'll see a message telling that IntelliSense is configuring libraries.


 * 1) Make sure that the target is set correctly, and then debug as normal. You'll see the output in the Linux Console Window on the bottom of Visual Studio (not in the bash shell or Command Prompt).

Usage
You can use it much like you'll debug a normal Windows program. The main exception is that features like CPU tracking are restricted, which is because the app is technically run elsewhere - on the Linux subsystem. One can easily set breakpoints, watch, locals and autos as normal. When (if?) a segmentation fault occurs, Visual Studio will halt the program and show the nearest location where the fault could have occurred (like what you'd get if you used  and enabled debugging symbols).

It is often possible to customise debugging settings. To do so would be the same as it's done on Windows - by going to Project Settings.