Experiments with WSL2... Yes you can use VSCode but could you run...
I'm a massive fan of WSL and now WSL2 is finally here (I've been using it during preview since day 1 but my work machine sadly couldn't run it until now...). With the Docker Desktop integration and some awesome I/O and performance metrics it really is good. This great article by Phoronix really shows how near native it is.
I often checkout some of my newer work code out in Ubuntu and then use VSCode for doing my work where appropriate however C# in VSCode is OK but it's not *great* VS2019 is still a better experience on the whole. About 2 months ago I tried JetBrains Rider 2020 out and although I liked it I couldn't quite justify using it on Windows instead of VS2019 which my work MSDN provides, however tonight I had a thought... Rider is cross platform, windows, macos and linux... could I get Rider running via WSL2 would it be awesome or horrible.... Let's find out....
22:00 Time to Start!
First I go to JetBrains website and go grab the download link for the Linux version: https://www.jetbrains.com/rider/download/#section=linux when you click the download you will get the tar.gz file and will be prompted where to save it. You could download to your Windows Downloads file and then copy to WSL but I chose to cancel it and instead copied the direct link.
With this link I crack open WSL and wget the file. It's worth providing an output file path or trimming the analytics tracking code as otherwise it downloads with a naff filename.
wget https://download.jetbrains.com/rider/JetBrains.Rider-2020.1.3.tar.gz
Once downloaded extract it: tar xvf JetBrains.Rider-2020.1.3.tar.gz, this will take a few mins...
Once extracted you can cd into the directory, theres a handy readme explaining how to run Rider on Linux but effectively cd to bin and run ./rider.sh . Now this will fail within WSL as you won't have a display yet.
22:20
But never fear, clever people have made it possible to run a X11 server via Windows and have WSL connect to it ... I know amazing! Open Windows Store and search for X11 there are a few available but I use X410, it costs but when its on offer its not too expensive. I'm going to assume you are using X410 but others will work fine. With X410 installed run it and you'll see the X icon saying its running. Originally on WSL1 this just worked but due to changes in WSL2 using Hyper-V you need to follow the instructions on the X410 website. Allow Public Access is a bit weird, hopefully WSL2 in the future will fix this (I know its on the radar).
Then run ./rider.sh again and you should see something different this time :D
You then need to activate a licence, you can get a 30 day trial licence if you want to experiment.
22:40
Everything is licenced and running :) So I hear you say.. yeah yeah is this really Rider within WSL... Open a solution ;)
Rather than mess around with a massive solution I thought for this post I'll create the inevitable Hello World Project.
I create it fine as I'd expect but... I try to NuGet Restore and Run and hit an issue :( Drat.
I decide to open the log and it's not super helpful, I then think to open the packages folder and get an error message I can do something about...
I create the missing folder and try again... same error :(
23:10
Hmm, bit stumped on this so will need to do some googling but let's try something different. Let's use dotnet cli to do the NuGet restore and then compile and run my app. NuGet restore worked fine :) Now lets run the app.... Hoorah!
23:20
So it appears to work fine in a basic sense, enough to try out on a real project and then find what works and what doesn't :D
Things I have noticed though:
- I have found the DPI scaling on W410 to not be great. High Quality is pretty good but not great, I can run without it and thing's aren't too bad.
- Rider's password manager won't work with the native keychain. In settings you can set to not store any or use KeePass. I'm currently using KeePass.
23:30
That's enough for tonight but it's worth trying out more for sure. I need to find what the root cause of the NuGet restore issue is as having to use the CLI does distract. Additionally although you can search NuGet for packages you can't install any which is a pain.
I didn't even expect to get this far at the start so the fact I have something working is amazing and something more people should look at doing, who knows maybe this could be a really productive way of developing .NET within a Linux not just using Docker or VSCode.
I will update this post as and when I get NuGet working and updated when I have tested this further.
Comments
Post a Comment