[英]dotnet command doesn't find new install of .NET Core 2.1
I am attempting to host ASP.NET Core applications on my Debian 9 server. 我试图在我的Debian 9服务器上托管ASP.NET核心应用程序。 I had previously installed .NET Core 1, and have been trying to install the runtime/hosting for .NET 2.1. 我以前安装过.NET Core 1,并且一直在尝试安装.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 我遵循了我的发布的官方安装说明 ,但是dotnet --version
命令输出1.0.1和dotnet --info
输出
.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... 果然,/ /opt/dotnet/shared/Microsoft.NETCore.App
只包含1.1.1和1.0.4的子目录,但......
$ 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. dpkg -L的输出很长,但我想我给出了问题的原因。 The files for the 2.1 runtime are all under /usr/share/dotnet
instead of /opt/dotnet
. 2.1运行时的文件都在/usr/share/dotnet
而不是/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. 运行dotnet
使用/usr/local/bin
中看到旧运行时的那个,但看起来有一个/usr/bin/dotnet
查看新版本......我按照Microsoft的说明进行了两次安装,所以我'我不确定为什么会这么不同。
When you enter dotnet
on your command line, your shell looks for it in your $PATH
. 当您在命令行中输入dotnet
时,您的shell会在$PATH
查找它。 You seem to have two dotnet
commands installed, one at /usr/local/bin/dotnet
, and another one at /usr/bin/dotnet
. 您似乎安装了两个dotnet
命令,一个位于/usr/local/bin/dotnet
,另一个位于/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/
首先出现在$PATH
这样当你输入dotnet
时你的shell运行/usr/local/bin/dotnet
dotnet
。
/usr/local/bin/dotnet
is, I suspect, a symlink to /opt/dotnet/dotnet
. 我怀疑/usr/local/bin/dotnet
是/opt/dotnet/dotnet
的符号链接。 That one contains 2 .NET Core runtime versions (as indicated by dotnet --info
): 1.0.4 and 1.1.1. 那个包含2个.NET Core运行时版本(由dotnet --info
指示):1.0.4和1.1.1。 It sounds like this was installed manually by a user, possibly by extracting from a release tarball to /opt/dotnet
. 听起来这是由用户手动安装的,可能是从发布tarball中提取到/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
. /usr/share/dotnet/
由dotnet-*
和aspnetcore*
软件包通过apt
。 And that contains verison 2.1 packages. 这包含verison 2.1包。
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. 如果/usr/local/bin/dotnet
不被包管理器(拥有dpkg --search /usr/local/bin/dotnet
没有列出一个包),那么你可以简单的rm
它。 Then dotnet
will mean /usr/share/dotnet/dotnet
. 然后dotnet
将意味着/usr/share/dotnet/dotnet
。 You can also remove /opt/dotnet
. 您也可以删除/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. 如果/usr/local/bin/dotnet
归包管理器所有,请在dpkg --search
输出中找到包的名称并删除该包。
You can override $PATH
in your .bashrc
(or equivalent shell profile). 您可以在.bashrc
(或等效的shell配置文件)中覆盖$PATH
。 Add a line like export PATH=/usr/bin:/usr/local/bin:/bin:/usr/game
. 添加一行如export PATH=/usr/bin:/usr/local/bin:/bin:/usr/game
。
I strongly recommend option 1. 我强烈建议选项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? 在您安装的版本发布后,安装说明可能已更改并且软件包可用吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.