Linux 上的 Blazor:错误 无法加载文件或程序集 System.Runtime



我在OpenSUSE Tumbleweed上,并从这个页面安装了Blazor:

https://learn.microsoft.com/en-us/dotnet/core/install/(从这里下载了特定的tar.gz文件:https://dotnet.microsoft.com/download/dotnet-core/3.0(

现在当我运行dotnet --version时,我得到 3.0.101。

所以我添加了如下所示的 Blazor 模板:

dotnet new -i Microsoft.AspNetCore.Blazor.Templates::3.1.0-preview4.19579.2

并尝试创建这样的项目:

dotnet new blazorwasm -o BlazorDemo
cd BlazorDemo
dotnet run

但是,该项目已创建 - 运行时出现此错误:

/home/petar/.nuget/packages/microsoft.aspnetcore.blazor.build/3.1.0-preview4.19579.2/targets/Blazor.MonoRuntime.targets(151,5): error MSB4062: The "BlazorCreateRootDescriptorFile" task could not be loaded from the assembly /home/petar/.nuget/packages/microsoft.aspnetcore.blazor.build/3.1.0-preview4.19579.2/targets/../tools/netcoreapp/Microsoft.AspNetCore.Blazor.Build.Tasks.dll. Could not load file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. [/home/petar/Blazor/BlazorDemo/BlazorDemo.csproj]
/home/petar/.nuget/packages/microsoft.aspnetcore.blazor.build/3.1.0-preview4.19579.2/targets/Blazor.MonoRuntime.targets(151,5): error MSB4062:  Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [/home/petar/Blazor/BlazorDemo/BlazorDemo.csproj]
The build failed. Fix the build errors and run again.

知道问题可能是什么吗?

正如 Agua 提到的 - 我使用的是 .NET 3.0。 但我使用的是 3.1 的模板。

所以 - 我删除了dotnet文件夹并再次安装了正确的版本:

  1. 本教程 - https://learn.microsoft.com/en-us/dotnet/core/install/sdk?pivots=os-linux
  2. 下载页面 - https://learn.microsoft.com/en-us/dotnet/core/install/sdk?pivots=os-linux#all-net-core-downloads

现在我可以在不受支持的 Linux 发行版上运行 Blazor:)

最新更新