I am attempting to host ASP.NET Core applications on my Debian 9 server. I had previously installed .NET Core 1, and have been trying to install the runtime/hosting for .NET 2.1.
I've followed the official installation instructions for my distribution, however the dotnet --version
command outputs 1.0.1, and dotnet --info
outputs
.NET Command Line Tools (1.0.1) Product Information: Version: 1.0.1 Commit SHA-1 hash: 005db40cd1 Runtime Environment: OS Name: debian OS Version: 9 OS Platform: Linux RID: debian.8-x64 Base Path: /opt/dotnet/sdk/1.0.1
when I try to run just the basic template application that I've copied to the server, it outputs
The specified framework 'Microsoft.NETCore.App', version '2.1.0' was not found. - Check application dependencies and target a framework version installed at: /opt/dotnet/shared/Microsoft.NETCore.App - The following versions are installed: 1.1.1 1.0.4 - Alternatively, install the framework version '2.1.0'.
Sure enough, /opt/dotnet/shared/Microsoft.NETCore.App
only contains subdirectories for 1.1.1 and 1.0.4, yet...
$ sudo apt install aspnetcore-runtime-2.1 [sudo] password for root: Reading package lists... Done Building dependency tree Reading state information... Done aspnetcore-runtime-2.1 is already the newest version (2.1.2-1).
What do I have to do to get the runtime to be found?
Answers to questions in comments:
$ which dotnet /usr/local/bin/dotnet
The output of dpkg -L is quite long, but I think gives me the reason for my problem. The files for the 2.1 runtime are all under /usr/share/dotnet
instead of /opt/dotnet
. Running dotnet
uses the one in /usr/local/bin
that sees the old runtime, but it looks like there's a /usr/bin/dotnet
that looks at the new version... I followed Microsoft's instructions for both installs, so I'm not sure why it's so different.
When you enter dotnet
on your command line, your shell looks for it in your $PATH
. You seem to have two dotnet
commands installed, one at /usr/local/bin/dotnet
, and another one at /usr/bin/dotnet
. /usr/local/bin/
appears first in your $PATH
so your shell runs /usr/local/bin/dotnet
when you type dotnet
.
/usr/local/bin/dotnet
is, I suspect, a symlink to /opt/dotnet/dotnet
. That one contains 2 .NET Core runtime versions (as indicated by dotnet --info
): 1.0.4 and 1.1.1. It sounds like this was installed manually by a user, possibly by extracting from a release tarball to /opt/dotnet
.
(These version are very out of date. They also contain known security vulnerabilities)
/usr/share/dotnet/
is installed by the dotnet-*
and aspnetcore*
packages via apt
. And that contains verison 2.1 packages.
You have a couple of options to fix this:
If /usr/local/bin/dotnet
is not owned by the package manager (dpkg --search /usr/local/bin/dotnet
doesn't list a package), then you can simply rm
it. Then dotnet
will mean /usr/share/dotnet/dotnet
. You can also remove /opt/dotnet
.
If /usr/local/bin/dotnet
is owned by a package manager, find the name of the package in the dpkg --search
output and remove that package.
You can override $PATH
in your .bashrc
(or equivalent shell profile). Add a line like export PATH=/usr/bin:/usr/local/bin:/bin:/usr/game
.
I strongly recommend option 1.
I am not sure why the two were installed in different locations and with different executibles. Perhaps the installation instructions were changed and packages were made available after the release of the versions you installed?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With