Troubleshooting my dotnet setup
I've recently been setting up dotnet
on my Artix Linux laptop for my course at University. While I'm unsure precisely what dotnet
is intended to do (and how it's different to Mono), my current understanding is that it's an implementation of .NET Core intended for developing and running ASP.NET web applications (there might be more on ASP.NET in a later 'first impressions' post soon-ish).
While the distribution is somewhat esoteric (it's based on Arch Linux), I've run into a number of issues with the installation process and getting Monodevelop to detect it - and if what I've read whilst researching said issues, they aren't confined to a single operating system.
Since I haven't been able to find any concrete instructions on how to troubleshoot the installation for the specific issues I've been facing, I thought I'd blog about it to help others out.
Installation on Arch-based distributions is actually pretty easy. I did this:
sudo pacman -S dotnet-sdk
Easy!
Monodevelop + dotnet = headache?
After this, I tried opening Monodevelop - and found an ominous message saying something along the lines of ".NET Core SDK 2.2 is not installed". Strange. If I try dotnet
in the terminal, I get something like this:
$ dotnet
Usage: dotnet [options]
Usage: dotnet [path-to-application]
.....
Turns out that it's a known bug. Sadly, there doesn't appear to be much interest in fixing it - and neither does there appear to be much information about how Monodevelop does actually detect a dotnet
installation.
Thankfully, I've deciphered the bug report and done all the work for you :P The bug report appears to suggest that Monodevelop expects dotnet
to be installed to the directory /usr/share/dotnet
. My system didn't install it there, so went looking to find where it did install it to. Doing this:
whereis dotnet
Yielded just /usr/bin/dotnet
. My first thought was that this was a symbolic link to the binary in the actual install directory, so I tried this to see:
ls -l /usr/bin/dotnet
Sadly, it was not to be. Instead of a symbolic link, I found instead what appeared to be a binary file itself - which could also be a hard link. Not to be outdone, I tried a more brute-force approach to find it:
sudo find / -mount -type d -name "dotnet"
Success! This gave a list of all directories on my main /
root partition that are called dotnet
. From there, it was easy to pick out that it actually installed it to /opt/dotnet
.
Instead of moving it from the installation directory and potentially breaking my package manager, I instead opted to create a new symbolic link:
sudo ln -s /opt/dotnet /usr/share/dotnet
This fixed the issue, allowing Monodevelop to correctly detect my installation of dotnet
.
Templates
Thinking my problems were over, I went to create a new dotnet
project following a tutorial. Unfortunately, I ran into a number of awkward and random errors - some of which kept changing from run to run!
I created the project with the dotnet new
subcommand like this:
dotnet new --auth individual mvc
Apparently, the template projects generated by the dotnet new
subcommand are horribly broken. To this end, I re-created my project through Monodevelop with the provided inbuilt templates. I was met with a considerable amount more success here than I was with dotnet new
.
HTTPS errors
The last issue I've run into is a large number of errors relating to the support for HTTPS that's built-in to the dotnet
SDK.
Unfortunately, I haven't been able to resolve these. To this end, I disabled HTTPS support. Although this sounds like a bad idea, my reasoning is that in production, I would always have the application server itself run plain-old HTTP - and put it behind a reverse-proxy like Nginx that provides HTTPS, as this separates concerns. It also allows me to have just a single place that implements HTTPS support - and a single place that I have to constantly tweak and update to keep the TLS configuration secure.
To this end, there are 2 things you've got to do to disable HTTPS support. Firstly, in the file Startup.cs
, find and comment out the following line:
app.UseHttpsRedirection();
In a production environment, you'll probably have your reverse-proxy configured to do this HTTP to HTTPS redirection anyway - another instance of separating concerns.
The other thing to do is to alter the endpoint and protocol that it listens on. Right click on the project name in the solution pane, click "Options", then "Run -> Configurations -> Default", then the "ASP.NET Core" tab, and remove the s
in `https in the "App URL" box like this:
By the looks of things, you'll have to do this 2nd step on every machine you develop on - unless you also untick the "user-specific" box (careful you don't include any passwords etc. in the environment variables in the opposite tab in that case).
You may wish to consider creating a new configuration that has HTTPS disabled if you want to avoid changing the default configuration.
Found this useful? Got a related issue you've managed to fix? Comment below!