asp.net arch linux 上的核心 2.1 没有 运行

asp.net core 2.1 on arch linux does not run

我已经在 Arch 上使用 pacman 安装了最新版本的 .net 核心 Linux:

sudo pacman -S dotnet-sdk

运行 dotnet --info 显示正确的版本:

Host (useful for support):
  Version: 2.1.0
  Commit:  caa7b7e2ba

.NET Core SDKs installed:
  2.1.0 [/opt/dotnet/sdk]
  2.1.300 [/opt/dotnet/sdk]

我可以 运行 控制台应用程序,但是当我 运行 dotnet run 在 ASP.NET 核心目录 return 中时出现此错误:

It was not possible to find any compatible framework version The specified framework 'Microsoft.AspNetCore.App', version '2.1.0' was not found.

为什么虽然版本似乎匹配,但实际上并不匹配 运行?

更多详情:

ls /opt/dotnet/sdk/ returns:

2.1.300  NuGetFallbackFolder

.csproj 文件的内容:

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>

</Project>

.NET Core 目前在 Arch 上不受支持,因此无法保证它会正常工作。目前 64 位支持以下发行版:

  • 红帽企业 Linux 7、6
  • CentOS 7
  • 甲骨文Linux7
  • 软呢帽 27
  • Debian 9、8.7 或更高版本
  • Ubuntu 18.04, 17.10, 16.04, 14.04
  • Linux 薄荷 18、17
  • openSUSE 42.3 或更高版本
  • SUSE Enterprise Linux (SLES) 12 Service Pack 2 或更高版本
  • Alpine Linux 3.7 或更高版本

有关详细信息,请参阅 this page

您可以在 dotnet 存储库中看到与 Arch 相关的这些问题:

https://github.com/dotnet/coreclr/issues/4409

https://github.com/dotnet/corefx/issues/19447

https://github.com/dotnet/core-setup/issues/3845

我没有适合您的问题的解决方案,但也许有解决方法。我正在使用 elementary os 和 .net core 2.1 工作得很好,但我注意到我的元包路径与你的不同:

.NET Core SDK (reflecting any global.json):
 Version:   2.1.300
 Commit:    adab45bf0c

Runtime Environment:
 OS Name:     elementary
 OS Version:  0.4.1
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /usr/share/dotnet/sdk/2.1.300/

Host (useful for support):
  Version: 2.1.0
  Commit:  caa7b7e2ba

.NET Core SDKs installed:
  2.0.0 [/usr/share/dotnet/sdk]
  2.1.300 [/usr/share/dotnet/sdk]

您可以尝试将元数据包从安装文件夹 /opt/dotnet/shared 复制到 /usr/share/dotnet/shared

这边的这个人在使用 Fedora 时遇到了类似的问题:https://github.com/dotnet/core-setup/issues/4022

@tura08 答案是错误的,因为 .NET Core 应该像在其他 Arch Linux 上一样工作 Linux系统.

我遇到了同样的问题,所以我刚刚报告了它 https://github.com/dotnet/core-setup/issues/4216 似乎 dotnet-sdk 包丢失 aspnetcore-runtime-2.1依赖。我给维护者写了邮件,所以我希望他能尽快修复包。

我在尝试安装全局工具时遇到了类似的问题。创建符号链接对我有用:

ln -s /opt/dotnet/ /usr/share/dotnet

升级所有软件包解决了问题:

pacman -Syu

它包含更新于 2018-06-12 11:24 UTC 的 dotnet-sdk 软件包 2.1.300-2: https://www.archlinux.org/packages/community/any/dotnet-sdk/

这个问题很老了,但如果有人试图让 .NET 5 在 Arch 上 运行,这可以为您提供另一个解决方案。

如果您构建、发布和运行指定平台的项目运行时间,dotnet将构建一个独立的应用程序,具有所有必要的平台特定依赖项。

您可以使用 --runtime/-r 标志来做到这一点。

Arch 示例:

dotnet build -r linux-x64
dotnet run -r linux-x64
dotnet publish -r linux-x64

有关可用的 运行 时间标识符,请参阅 Microsoft 文档: https://docs.microsoft.com/en-us/dotnet/core/rid-catalog


编辑:

我使用 AUR 包而不是 Snap 的路径问题也更少:

https://aur.archlinux.org/packages/dotnet-sdk-bin/


编辑 2:

安装 AUR 的 aspnet-runtime-bin 包后,所有关于 Microsoft.AspNetCore.App not being found 的错误都消失了,没有使用 --runtime 标志:

https://aur.archlinux.org/packages/aspnet-runtime-bin