Visual Studio on Linux
Visual Studio on Linux
Want to run C# on a Linux VM? Get a head start here with this handy tutorial that shows you how to get set up with Kubuntu.
Join the DZone community and get the full member experience.Join For Free
For my upcoming presentation “ASP.NET Core on Linux” I need Linux VM I can access with a remote desktop to run Visual Studio Code. After hours of many different problems that built up fast over my head I was able to make things work and now I have functioning VM I can use for demos. This post is a short overview about how I did what I did and is for readers who also want to have Linux VM with Visual Studio Code.
- RDC connection is way more user-friendly than Hyper-V window or some VNC window
- works okay but not with Gnome desktop
- xrdp works okay with xfce but Visual Studio Code has issues with it
- Installing K on Ubuntu with Gnome ended up with errors and crashes
NB! I’m very sure I did something wrong or had not enough knowledge and skills for more complex configuring of Linux environment. If you know more or you have a friend who is a Linux guru then you can perhaps use some other setup of a Linux environment. I’m just a happy n00bie here!
Let’s start with creating our Hyper-V virtual machine. To save time it’s a good idea to start the Kubuntu download before it. I created a VM with the following properties:
- No secure boot enabled
- 2 virtual cores
- 2048 MB RAM
- Network switch with access to local network
- 15GB HDD
I attached a Kubuntu image as a DVD, ran Kubuntu, and opened VM in the Hyper-V window. Installation is actually easy – it’s just stepping through some dialogs and inserting user account information in the end. Installation went pretty fast – had time for one quick coffee and cigarette. After installation, Kubuntu required installation media to be removed and VM to be restarted. If there were no issues then Kubuntu is ready to go.
Installing and Configuring xrdp
As a next step, I made remote access work. It was a simple process too.
- Open terminal and install Krfb:
sudo apt-get install Krfb
- Run Krfb and configure remote access like described in official documentation page Using Desktop Sharing
- Install xrdp:
sudo apt-get install xrdp
sudo system restart xrdp
- Try to access VM using RDC from Windows box.
Installing .NET Core and Visual Studio Code
I installed .NET Core and Visual Studio Code.
- There is a problem with libicu55 library that must be installed manually. For this, follow the steps provided by Shannon Deminick’s post Installing .NET Core 1.01 on Ubuntu 16.10.
- Open terminal window and type the following commands (more information is available on .NET Core homepage):
sudo sh -c ‘echo “deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ xenial main” > /etc/apt/sources.list.d/dotnetdev.list’
sudo apt-key adv –keyserver apt-mo.trafficmanager.net –recv-keys 417A0893
sudo apt-get update
sudo apt-get install dotnet-dev-1.0.0-preview2-003131
- Open browser, got VS Code homepage, and download Ubuntu package. Make sure you save it on the hard disk.
- In terminal window move to folder where VS Code was downloaded and run the following command:
sudo dpkg -i vs-code-deb-file-name-here.deb
- Install Git using the following command:
sudo apt-get install git
If there were no errors then Visual Studio Code should start with no issues when logged in using Remote Desktop.
It was easy to get everything to work once I figured out what the problem was. But figuring this out takes a lot of time if you're not familiar with Linux. Once everything works it's easy enough to make more configuration changes. Actually, Linux works just fine and for Windows dudes, it’s more of a question about figuring which things work together. Anyway, my environment for ASP.NET of Linux presentation is now ready to go.
Published at DZone with permission of Gunnar Peipman , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.