您必须安装或更新 .NET 才能运行此应用程序 - 错误

问题描述 投票:0回答:1

我正在尝试安装.net并尝试使用 101 个 LINQ 示例来学习 LINQ。我已按照 github 页面上的说明进行操作:https://github.com/dotnet/try-samples#basics,但是当我尝试运行时

dotnet run

在我的终端中,我收到此错误:

You must install or update .NET to run this application.

App: /Users/bulatpochanov/.dotnet/tools/dotnet-try
Architecture: arm64
Framework: 'Microsoft.AspNetCore.App', version '3.1.0' (arm64)
.NET location: /usr/local/share/dotnet

The following frameworks were found:
  6.0.21 at [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  7.0.9 at [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
  7.0.10 at [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]

Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failed

To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=3.1.0&arch=arm64&rid=osx.12-arm64

我尝试安装版本 3.1.0 框架,但随后出现此错误:

You must install or update .NET to run this application.

App: /Users/bulatpochanov/.dotnet/tools/dotnet-try
Architecture: arm64
Framework: 'Microsoft.AspNetCore.App', version '7.0.10' (arm64)
.NET location: /usr/local/share/dotnet

The following frameworks were found:
  3.1.0 at [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]

Learn about framework resolution:
https://aka.ms/dotnet/app-launch-failed

To install missing framework, download:
https://aka.ms/dotnet-core-applaunch?framework=Microsoft.AspNetCore.App&framework_version=3.1.0&arch=arm64&rid=osx.12-arm64

然后,我尝试配置前滚行为,以使应用程序能够与较新版本的 .net 一起使用,如下所示:https://learn.microsoft.com/en-us/dotnet/core/runtime -发现/故障排除应用程序启动?pivots=os-windows#configure-roll-forward-behavior 但是,您需要在运行

dotnet --roll-forward Major specifiedFile
时指定文件,这让我很困惑,因为
dotnet try
应该打开一个包含所有 LINQ 示例的浏览器窗口。

如果有帮助,这里是来自微软频道的视频,

dotnet try
应该如何工作:https://www.youtube.com/watch?v=p5myHVOtmiU

c# asp.net .net .net-sdk
1个回答
0
投票

我的电脑也遇到了类似的情况,问题已通过以下步骤解决:

环境:

操作系统:Win 11

.NET SDK:已安装.NET Core 3.0 SDK、.NET Core 3.1 SDK、.NET 6.0 SDK、.NET 8.0 SDK。

1.确保您安装了最新版本的“dotnet try”工具。

如果使用命令“dotnet tool install -g dotnet-try”安装它,则需要先卸载它:

dotnet tool uninstall -g dotnet-try

如果使用命令“dotnet tool install -g Microsoft.dotnet-try”安装它,则需要先卸载它:

dotnet tool uninstall -g Microsoft.dotnet-try

然后使用以下命令安装最新版本的“dotnet try”: dotnet 工具安装-g --add-source "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-tools/nuget/v3/index.json" Microsoft.dotnet-try

在Windows中,建议以管理员权限在“cmd”中运行以上命令。

2.确保您安装了.NET 3.0和.NET 3.1 SDK

您可以运行以下命令来检查:

dotnet --list-sdks

如果您没有安装它们,请从下面的链接下载并安装它们。

https://dotnet.microsoft.com/en-us/download/dotnet/3.0 https://dotnet.microsoft.com/en-us/download/dotnet/3.1

注意:目前.NET core 3.1 SDK的版本为“3.1.416”。

3.使用 git shell 使用以下命令克隆代码

git clone https://github.com/dotnet/try-samples

4.在“try-samples”文件夹的根目录下创建global.json:

内容如下:

{
  "sdk": {
    "version": "3.1.416"
  }
}

注意:此处的版本“3.1.416”应与步骤2中的相同。

5.尝试使用“dotnet try verify”命令编译它

cd try-samples/
dotnet try verify

如果没有发生异常,请跳至下面的下一步。 否则尝试从所有 .csproj 文件中删除对包“System.CommandLine.Experimental”的引用。

6.运行“dotnet try”命令在浏览器中打开网页:

dotnet try ".\101-linq-samples"

7.尝试网络上的示例。

点击下面截图中的链接:

Step 1 - click

选择一个例子:

Step 2 - click

运行结果:

Running result

愿对您有帮助!祝你好运!


参考资料:

https://github.com/dotnet/try/blob/main/DotNetTryLocal.md

https://github.com/dotnet/try/issues/938#issuecomment-1023604536

© www.soinside.com 2019 - 2024. All rights reserved.